Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. class Debug1 extends Frame implements ActionListener {
  2.     TextField text = new TextField(20);
  3.     Button b;
  4.     private int numClicks = 0;
  5.     public static void main(String[] args) {
  6.         Debug1 myWindow = new Debug1("My first window");
  7.         myWindow.setSize(350,100);
  8.         myWindow.setVisible(true);
  9.     }
  10.     public Debug1(String title) {
  11.         super(title);
  12.         setLayout(new FlowLayout());
  13.         b = new Button("Click me");
  14.         add(b);
  15.         add(text);
  16.         b.addActionListener(this);
  17.     }
  18.     public void actionPerformed(ActionEvent e) {
  19.         numClicks++;
  20.         text.setText("Button Clicked " + numClicks + " times");
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement