devxlogo

January 13, 2000

Split Strings Cleanly

The Split function is great for parsing strings, but what happens when a string has more than one consecutive delimiter? It might seem odd that Split() returns empty substrings as

Change the Gray Applet Background

Applets use a default background of gray, which may not be visually appealing to you. Besides, gray may be the background color of the web page on which the applet

Java Consoles Show What’s Going On With Applets

Modern Java IDEs like Symantec’s Visual Cafe and Inprise’s JBuilder offer advanced applet debugging facilities. However, if you develop your applets using only the freely distributed JDK, it might be

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

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

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

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

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

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;