-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleRB.java
More file actions
63 lines (57 loc) · 1.7 KB
/
Copy pathSimpleRB.java
File metadata and controls
63 lines (57 loc) · 1.7 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class SimpleRB extends JFrame implements ActionListener
{
JRadioButton fyButton, syButton, tyButton;
ButtonGroup classGroup;
JTextField classField;
JButton applyButton;
public SimpleRB() {
// Set up the frame
setTitle("Radio Button Form");
setSize(200, 200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new GridLayout(4, 3, 10, 10));
classField = new JTextField("");
// Your Class
JLabel classLabel = new JLabel("Your Class:");
JPanel classPanel = new JPanel();
fyButton = new JRadioButton("FY");
syButton = new JRadioButton("SY");
tyButton = new JRadioButton("TY");
classGroup = new ButtonGroup();
classGroup.add(fyButton);
classGroup.add(syButton);
classGroup.add(tyButton);
classPanel.add(fyButton);
classPanel.add(syButton);
classPanel.add(tyButton);
add(classLabel);
add(classPanel);
applyButton = new JButton("Apply Changes");
applyButton.addActionListener(this);
add(applyButton);
add(classField);
setVisible(true);
}//constructor
@Override
public void actionPerformed(ActionEvent e) {
// Get class
String className = "";
if (fyButton.isSelected()) {
{
className = "FY";
}
} else if (syButton.isSelected()) {
className = "SY";
} else if (tyButton.isSelected()) {
className = "TY";
}
classField.setText(className);
}
public static void main(String[] args)
{
new SimpleRB();
}
}