import javax.swing.*; import java.awt.*; import java.awt.event.*; /* */ public class UpDownButton2 extends JApplet { 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); } }