Tip Bank

DevX - Software Development Resource

On Throwing Exceptions From Constructors

It sometimes makes a lot of sense to throw an exceptionfrom the constructor of a class; look at constructors ofthe java.net.URL for an example. But what do we do if

DevX - Software Development Resource

Paint Outside The GUI Thread

A call to repaint() will schedule a component to be repainted when the gui thread is free. But what if we can’t wait till then? Well, we can use the

DevX - Software Development Resource

Load an HTML Page From Within an Applet

Applets are executed within a web browser, and there’s an easy way to load show a specific URL. 1. Get a reference to the applet context 2. Call the showDocument

DevX - Software Development Resource

See Which Fonts Are Installed With Your VM

Sometimes, it is useful to know which fonts are installed. This can differ from one Java Virtual Machine (JVM) implementation to another. The following code displays the names of all

DevX - Software Development Resource

Get a Hold of the Bits in Your Integers

Sometimes, it is useful to obtain a binary representation of integer, or a character. For example, we might want to represent the character ‘a’ by its binary 01100001, the letter

DevX - Software Development Resource

Trigonometry With Java

The java.lang.Math package has useful trigonometric functions such as: public static native double sin(double a) public static native double asin(double a). So, if we write code: double x = 90;

DevX - Software Development Resource

Using ShowHelp with Windows 95 and NT

Question: When we call the ShowHelp function in Windows 95, it works with a topic ID but not with a keyword. However, the same source works just the opposite in

DevX - Software Development Resource

Swap Images With JavaScript

A nice touch to a Web page is a button that changes appearance when clicked. All you need is two GIFs and a little JavaScript. The following code initially displays