ClickListener.java
A simple subclass of MouseAdapter that reports where the mouse
was pressed. When attached to an applet, look for the report
in the Java Console.
ClickReporter.html
An HTML file used to invoke the ClickReporter applet. Remember
to R-click on the link and download the HTML file -- don't
try to L-click and run the applet -- we don't have the .class
files online, just the source code.
CircleListener.java
A subclass of MouseAdapter that draws a circle wherever
mouse was pressed. Illustrates first approach to event-handling
with listeners: attaching a separate listener.
CircleDrawer1.html
An HTML file used to invoke the CircleDrawer1 applet.
Remember to R-click on the link to download the HTML file.
CircleDrawer2.java
Applet that uses itself to handle mouse events and draw circles.
Illustrates second approach to event-handling with listeners:
implementing a listener interface.
CircleDrawer2.html
An HTML file used to invoke the CircleDrawer2 applet.
Remember to R-click on the link to download the HTML file.
CircleDrawer3.java
Applet that uses a named nested class to handle mouse events and draw circles.
Illustrates third approach to event-handling with listeners:
using inner classes.
CircleDrawer3.html
An HTML file used to invoke the CircleDrawer3 applet.
Remember to R-click on the link to download the HTML file.
CircleDrawer4.java
Applet that uses a anonymous nested class to handle mouse events and draw circles.
Variation on third approach to event-handling:
using inner classes.
CircleDrawer4.html
An HTML file used to invoke the CircleDrawer4 applet.
Remember to R-click on the link to download the HTML file.
MouseReporter.java
Applet that uses processXxx methods to print detailed
reports on mouse events. Illustrates low-level alternative
to handling events with listeners.
MouseReporter.html
An HTML file used to invoke the MouseReporter applet.
Remember to R-click on the link to download the HTML file.
LanguageField.java
A TextField that uses key events to correct the spelling of
the names of computer languages entered into it.