Introduction to Java Interface Event-Handling : Page 2
Java is an event-driven language. This means that program flow usually varies dependent upon what actions a user performs, and differs from traditional procedural-based languages where program execution was very linear. Here's what you need to know to make your Java programs respond to events such as the user moving the mouse or clicking a button.
by David M. Williams
Oct 21, 2002
Page 2 of 4
Listing 1 contains the code for a simple Java applet that displays a button. When a user clicks the button the code changes the background color of the button in a round-robin fashion based on a index into the private strColors array. Because it's an applet, you cannot run it directly as a Windows applicationit must be embedded into an HTML page. Listing 2 gives the HTML tags for such a page.