import java.awt.*; import java.awt.event.*; public class AnonTest { private Frame f; private TextField tf; public static void main(String args[]) { AnonTest obj = new AnonTest(); obj.go(); } public void go() { f = new Frame("Anonymous classes example"); f.add(new Label("Click and drag the mouse"), BorderLayout.NORTH); tf = new TextField (30); f.add (tf, BorderLayout.SOUTH); f.addMouseMotionListener (new MouseMotionAdapter() { public void mouseDragged (MouseEvent e) { String s = "Mouse dragging: X = "+ e.getX() +" Y = " +e.getY(); tf.setText (s); } } ); f.addMouseListener (new MouseClickHandler()); f.setSize(300, 200); f.setVisible(true); } }