| Andreas Rozek |
|
Clock AppletThe "Clock" applet periodically displays the actual time. It is a simple example for a "real" applet which uses the "Placeholder" technique to seamlessly integrate an applet into an HTML document. Technical DescriptionInstead of re-implementing the code of "Placeholder", "Clock" simply "extends" that applet. A look into the source code illustrates where "Placeholder" methods have to be called in order to use their functionality: public class Clock extends Placeholder {
public void init () {
super.init(); // handles any given parameters
...
};
public synchronized void paint (Graphics Graf) {
super.paint(Graf); // draw background
...
};
};
By this means, inheritance significantly simplifies applet programming. However, please note the following details:
Applet Parameters"Clock" uses the same applet parameters as "Placeholder" (which are repeated here for sake of completeness only):
A typical invocation of the "Clock" applet may therefore look as follows: <APPLET code=Clock.class width=80 height=20>
<PARAM name="Background" value="./Textures/Paper.jpg">
<PARAM name="XOffset" value="0"><PARAM name="YOffset" value="0">
</APPLET>
Example
Source CodeThe source code of this applet is available for download:
|
| http://www.Andreas-Rozek.de/Java/Applets/Clock.html | (last Modification: 23.04.2002) |