January 7, 2000

Track Clicks on Element With Expando Property

Browsers Targeted: Internet Explorer 4 and 5 With Internet Explorer 4.0 and above, you can create an arbitrary property on any HTML object. This property, called an expando property, stays associated with the object as long as the object exists. For example, if you wanted to keep track of the

Using the SetTimeout() Function

Browsers Targeted: Internet Explorer 3+, Netscape 3 and 4 Sometimes, you need to set up events to happen at periodic intervals. Perhaps the simplest application of this is a clock. While both JavaScript and VBScript have time functions (through the Date object), a clock requires that you update this time

Recursively Delete Directories in Java

In Java, a readable, writable directory should be empty before an attempt is made to remove it. The following code recursively empties a directory, and its sub-directories, and then removes them. private void deleteFile(File p_file) { String FILE_SEPARATOR = System.getProperty(“file.separator”); // If it is a directory, empty it first System.out.println(“Deleting:

Resize Applets in Browsers

With applets, sometimes the browser acts as the applet’s frame. This prevents the user from mistaking the browser window for a separate application and closing it. With this approach, the applet does not resize itself as the user resizes the browser?but there are ways to do this. The problem is

Textfield With Limited Length Of Characters

Sometimes it is useful to have a text field, for which you can specify a max number of characters. The following class give you just that: import java.awt.*; import java.awt.event.*; public class LimitedLength_TextField extends TextField implements KeyListener { private int maxLength; public LimitedLength_TextField (String str,int cols,int maxLength) { super(str,cols); this.maxLength

Add Background Image to JTable

You can easily add a background image to swing’s JTable. The following code shows you how: Note that the image scrolls with the table. public class BackgroundTable { public static void main(String[] args) JFrame frame = new JFrame(“Table Example”); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { Window w

Get Rid Of Unreadable Characters

Line separators are dependent on the operating system. This may cause some annoyance when opening files created on another operating system. For example, if you are using Microsoft Windows, and you open a text file created on UNIX, you may see some hardly readable text that goes on for a

Provide Data Tip For JTable Columns

Cell data in a table may exceed the width of its column. It is a good, user-friendly, idea to have ToolTips appear in a cell showing the entire cell data as the user brings the mouse over the cell. This can easily be done using JTable and a few lines

Java’s Division and Modulus Operations

In Java you take the remainder with the modulus (%) operator, whereby the sign of the remainder follows the dividend, not the divisor. So (+5 % -2) will be, to the surprise of many, +1. Java division has the Euclidean property. When you multiply the quotient by the divisor and