// We used inheritance to create this variation of the built-in Frame class so // that it would draw some shapes and respond to mouse clicks and drags. import java.awt.*; public class CustomFrame extends Frame { private int count; private int oldX, oldY; public void paint(Graphics g) { count++; System.out.println("paint count = " + count); g.drawString("hello world!", 50, 50); g.setColor(Color.YELLOW); g.fillRect(50, 100, 30, 30); } public boolean mouseDown(Event e, int x, int y) { Graphics g = getGraphics(); g.setColor(Color.BLUE); g.fillOval(x - 5, y - 5, 10, 10); oldX = x; oldY = y; return true; } public boolean mouseDrag(Event e, int x, int y) { Graphics g = getGraphics(); g.setColor(Color.RED); g.drawLine(oldX, oldY, x, y); oldX = x; oldY = y; return true; } }