HyperComponent (v1.0)

Centre for Computational Geography
University of Leeds

This isn't an Applet, it's a class you can use with an Applet if you're a Java developer. It converts any java.awt.Component extending class into a Hypertext link which can open in a named frame or new browser window.

For an example see this webpage.

You'll need the class file HyperComponent.class (v1.1) and to know that it's in the package uk.ac.leeds.ccg.awt. Look at the information below to see how to use the class. Currently there are some problems with using the class in a GridBagLayout. For some reason adding the HyperComponent fills two cells. If this happens, the solution is to make the HyperComponent (which will give the starting Component the Mouse-related behaviour) and then add the original Component to the GridBag rather than the HyperComponent. The information below will get you started. For more information, see the docs.

Essential Constructor parameters:
HyperComponent (Component component, URL url, Applet applet)

Component component
The java.awt.Component extending class you wish to hyperlink.

URL url
A java.net.URL object representing the webpage or cgi program you wish to link to. Note that this is not checked for existance and that "javascript:" is not an appropriate protocol (see below).

Applet applet
A reference to the Applet you make the HyperComponent in. You can pass this from the Applet to the HyperComponent using "this", i.e. new HyperComponent(component,url,this).

Optional Constructor parameters:
HyperComponent (Component component, URL url, String target, Color highlight, Applet applet)

String target
Optional. The frame name to connect to. By default this is the "_parent" window - i.e. that which the Applet is in. To get a component to pop up a javascript window, make a webpage that pops up the javascript window, and use the component to open the webpage in a hidden (zero-size) frame at the bottom of your applet webpage.

Color highlight
Optional. An optional colour for the component's foreground. This will replace the standard foreground colour when the mouse is over the component, matching the stylesheet a:hover behaviour of web links.

This class may be freely used by academic and non-profit, non-governmental organisations, as well as private individuals. Other organisations should contact the CCG for information on its use.

For further information about this class and the source code, contact Dr Andy Evans.

[CCG homepage] [School of Geography homepage]