COMP2396
Loading...
Searching...
No Matches
SimpleGUI2.java
Go to the documentation of this file.
1import javax.swing.*;
2import java.awt.event.*;
3
4public class SimpleGUI2 implements ActionListener {
5 JButton button;
6 public static void main(String[] args) {
7 SimpleGUI2 gui = new SimpleGUI2();
8 gui.go();
9 }
10
11 public void go() {
12 JFrame frame = new JFrame();
13 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
14 button = new JButton("click me");
15 button.addActionListener(this);
16 frame.add(button);
17 frame.setSize(300, 300);
18 frame.setVisible(true);
19 }
20
21 public void actionPerformed(ActionEvent event) {
22 button.setText("I've been clicked!");
23 }
24}
void actionPerformed(ActionEvent event)
static void main(String[] args)