static final int x1 = 145, y1 = 120, width1 = 60, height1 = 60; static final int x2 = 100, y2 = 100, width2 = 150, height2 = 100; public TestAWT3(){ this.setSize(400,300); Label l1 = new Label("Click Window!"); this.add(l1,BorderLayout.NORTH); this.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent mevent) { Graphics gr = getGraphics(); gr.setColor(Color.orange); gr.fillRect(x2, y2, width2, height2); gr.setColor(Color.red); gr.fillOval(x1, y1, width1, height1); } }); this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent wevent) { System.exit(0); } }); }