Java Graphics 1.0
- public class Swing1 extends Frame {
- int count = 0;
- public Swing1 () {
- Button button = new Button ("Go"); add (button);
- Label out = new Label ("000", Label.CENTER); add (out);
- button.addActionListener (new MyActionListener(this, out));
-
- }
- }
- class MyActionListener implements ActionListener {
- private Swing1 parent;
- private Label out;
- public MyActionListener (Swing1 parent, Label out) { this.parent = parent; this.out = out; }
- public void actionPerformed (ActionEvent e) {
- parent.count += 1;
- out.setText (String.format ("%03d", parent.count));
- out.repaint ();
- }
- }