-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleCBB.java
More file actions
41 lines (35 loc) · 1.1 KB
/
Copy pathSimpleCBB.java
File metadata and controls
41 lines (35 loc) · 1.1 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
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class SimpleCBB extends JFrame implements ActionListener
{
JComboBox<String> cityComboBox;
JTextField classField;
JButton applyButton;
public SimpleCBB() {
// Set up the frame
setTitle("Check Box Form");
setSize(300, 300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new GridLayout(4, 3, 10, 10));
classField = new JTextField("");
JLabel cityTypeLabel = new JLabel("City:");
cityComboBox = new JComboBox<>(new String[]{"Pune", "Latur", "Amravati","Mumbai","Solapur"});
add(cityTypeLabel);
add(cityComboBox);
applyButton = new JButton("Apply Changes");
applyButton.addActionListener(this);
add(applyButton);
add(classField);
setVisible(true);
}//constructor
@Override
public void actionPerformed(ActionEvent e) {
String myCity = (String) cityComboBox.getSelectedItem();
classField.setText(myCity);
}
public static void main(String[] args)
{
new SimpleCBB();
}
}