COMP2396
Loading...
Searching...
No Matches
SimpleGUI2.java
Go to the documentation of this file.
1
import
javax.swing.*;
2
import
java.awt.event.*;
3
4
public
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
}
SimpleGUI2
Definition
SimpleGUI2.java:4
SimpleGUI2.go
void go()
Definition
SimpleGUI2.java:11
SimpleGUI2.actionPerformed
void actionPerformed(ActionEvent event)
Definition
SimpleGUI2.java:21
SimpleGUI2.main
static void main(String[] args)
Definition
SimpleGUI2.java:6
chapter8
SimpleGUI2.java
Generated on Sat Dec 7 2024 17:10:09 for COMP2396 by
1.12.0