import java.applet.*; import java.awt.*; import java.awt.event.*; public class MyDrawing extends Applet implements ActionListener { public void init() { buttonLeft = new Button ("Left"); add(buttonLeft); buttonLeft.addActionListener(this); buttonRight = new Button ("Right"); add(buttonRight); buttonRight.addActionListener(this); } public void paint ( Graphics g) { g.setColor(Color.blue); g.drawLine(100+x, 100+x, 50, 50); g.setColor(Color.yellow); g.fillRect(150+x, 150+x, 50+x, 50+x); g.setColor(Color.black); g.drawRect(150+x, 150+x, 50+x, 50+x); g.setColor(Color.blue); g.fillOval(250+x, 150+x, 100-x, 100-x); g.setColor(Color.yellow); g.drawOval(250+x, 150+x, 100-x, 100-x); g.setColor(Color.blue); g.drawLine(120+x, 120-x, 200, 200); g.setColor(Color.yellow); g.fillRect(150-x, 150-x, 50-x, 50-x); g.setColor(Color.black); g.drawRect(150-x, 150-x, 50-x, 50-x); g.setColor(Color.blue); g.fillOval(350+x, 150+x, 100+x, 100+x); g.setColor(Color.yellow); g.drawOval(350+x, 150+x, 100+x, 100+x); } public void actionPerformed (ActionEvent e) { if (e.getSource ()== buttonLeft) { x = x - 10; } if (e.getSource() == buttonRight) { x = x + 10; } repaint(); } int x = 0; Button buttonLeft, buttonRight; }