/* This is a modification of ClickableRandomStrings.java that uses an anonymous subclas of MouseAdapter for event handling. */ import java.awt.event.*; public class ClickableRandomStrings2 extends RandomStrings { public void init() { // When the applet is created, do the initialization // of the superclass, RandomStrings. Then add a // mouse listener to listen for mouse events on the // "drawingSurface". (The drawingSurface variable // is defined in the RandomStrings class and // represents a component that fills the entire applet.) super.init(); drawingSurface.addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent evt) { // When user presses the mouse, tell the system to // call the drawingSurface's paintComponent() method. drawingSurface.repaint(); } } ); } // end init() } // end class ClickableRandomStrings