// Step 2: Add interaction // The awt library // Author: Carsten Schuermann import javax.swing.JFrame; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; public class DotFrame extends JFrame { public DotFrame(){ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(400, 400); setTitle("DotFrame"); class IC extends MouseAdapter { public void mouseClicked(MouseEvent e) { drawDot( e.getX(), e.getY() ); } } class ICC extends MouseAdapter { public void mouseClicked(MouseEvent e) { drawDot(10+ e.getX(), 1+e.getY() ); } } this.addMouseListener(new IC ()); this.addMouseListener(new ICC ()); setVisible(true); } private void drawDot(int x, int y) { getGraphics().fillOval(x-5, y-5,10,10); } public static void main(String[] args) { new DotFrame (); } }