Kai Button

Last updated: 08.05.2002


KaiButton

The KaiButton class was written years ago, before rollovers started appearing everywhere on the Web, and was loosely inspired by the buttons in some software packages, such as those developed by Kai Krause, (e.g. Kai's Power Tools and KPT Bryce). In these systems, buttons that aren't in use tend to fade into the background to avoid cluttering the interface, rather like this one:

[Click Me]

The button above doesn't do anything (except print a little error message in the status line when you click on it, because I didn't give it a URL to go to), but the ones below will let you inspect the three source files that are used to create this effect.

View Source [KaiButtonApplet] [WebKaiButton] [buttonKaiButton] *

The applets are the product of three classes: the basic functionality is provided by the KaiButton class, which is adapted for use on the Web by the WebKaiButton class, which extends the basic KaiButton to handle clicks by sending the user's browser to a new URL. The buttons are contained in a demonstrator applet class, KaiButtonApplet which does the work of fetching the images used. The applet uses a media tracker to ensure that all the images are loaded before the button is displayed.

If you don't have Java switched on (or your browser doesn't support it) you'll still see the buttons on the page, but they won't change their appearance in response to enter events or clicks.

The same effect can actually be achieved rather more easily and quickly using Javascript for those browsers that support it. As far as the Web's concerned, JavaScript is better for this kind of application than Java. However, this implementation might be of interest if you're building a Java application and would like to use animated buttons.

* Documentation and Sources

Menu
Java
Links
Notes
Software
JavaScript
Perl
Python
Macintosh
Palm

Java[UP][LINKS][HOME]