-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlphaSwing.java
More file actions
43 lines (33 loc) · 1.06 KB
/
AlphaSwing.java
File metadata and controls
43 lines (33 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class AlphaSwing {
AlphaSwing() {
JFrame jfrm = new JFrame("Book Example");
jfrm.setSize(900, 800);
jfrm.setLayout(new FlowLayout());
jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton alp = new JButton("Alpha");
jfrm.add(alp);
JButton beta = new JButton("Beta");
jfrm.add(beta);
JLabel jlb = new JLabel("Result will appear here");
jfrm.add(jlb);
alp.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent ae) {
jlb.setText("Alpha");
}
});
beta.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent ae) {
jlb.setText("Beta");
}
});
jfrm.setVisible(true);
}
public static void main(String[] args) {
new AlphaSwing();
}
}