Yet another silly Java applet
Source code for the clock applet.
This is a clock whose hand goes around when you press the "Tick"
button. The point for me was to learn about threads.
A thread is an independent process other than the main process
running the applet. In this example, the thread is a "ticker"
that redraws the screen with the hand advanced one "hour",
waits a second, and repeats, until you press the "Stop"
Eventually this applet will do some demonstrations of clock
arithmetic, related to my
Number Bracelets page.
A simple Java example for beginners
Most of the examples of Java code I have found are either really simple,
and totally useless (e.g., buttons that don't do anything) or
are written by experienced programmers, and I can't understand them.
So, as a public service to not-very-good programmers like me
who are struggling to learn Java, I am offering some programs
that do a few things and illustrate basic concepts.
I have tried to include helpful comments on things I found confusing.
User Interface: TextFields and Buttons
This is an example which illustrates two User Interface components:
TextFields and Buttons. Clicking on the buttons affects the
entry in the TextField, as does typing in the TextField.
Specifically: you can enter a base 10 number in the TextField
using the calculator buttons (0 and 1) or by typing.
The = button computes the residue mod 2.
The C button clears the TextField to 0.
If you type in anything other than an integer, the screen is reset to
0 when you press =. Weird things happen when you enter more than
10 digits: watch the diagnostic on stdout.
The applet: DumbCalc.
You need a Java-enabled browser (such as Netscape 2.0 for Windows or
Unix, or HotJava) to run it. Rumor has it that something will
be available for Macintoshes this spring.
The official Java site,
which includes the Java Developer's Kit and full documentation online.
To Susan Addington's Geometry Center Home Page