import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

/* <applet code="UpDownButton2.class" width="200" height="70"></applet> */

public class UpDownButton2 extends JApplet {
  String str = "Hello World!";
  int x=20;
  JButton left, right;

  public class LeftListener implements ActionListener {
    public void actionPerformed(ActionEvent e) {
      x-=10;
      repaint();
    }
  }

  public class RightListener implements ActionListener {
    public void actionPerformed(ActionEvent e) {
      x+=10;
      repaint();
    }
  }

  @Override  
  public void init() {
    left  = new JButton("Left");
    right = new JButton("Right");
    left.addActionListener(new LeftListener());
    right.addActionListener(new RightListener());
    setLayout(new FlowLayout());
    add(left); add(right);
  }

  @Override
  public void paint(Graphics g) {
    super.paint(g);
    g.drawString("HELLO WORLD!", x, 55);
  }
}
