-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleList.java
More file actions
43 lines (37 loc) · 1.19 KB
/
Copy pathSimpleList.java
File metadata and controls
43 lines (37 loc) · 1.19 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.*;
import java.util.*;
public class SimpleList extends JFrame implements ActionListener
{
JList<String> cityList;
JTextField classField;
JButton applyButton;
public SimpleList() {
// 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:");
cityList = new JList<>(new String[]{"Pune", "Latur", "Amravati","Mumbai","Solapur"});
cityList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
add(cityTypeLabel);
add(cityList);
applyButton = new JButton("Apply Changes");
applyButton.addActionListener(this);
add(applyButton);
add(classField);
setVisible(true);
}//constructor
@Override
public void actionPerformed(ActionEvent e) {
List<String> myList = cityList.getSelectedValuesList();
classField.setText(myList.toString());
}
public static void main(String[] args)
{
new SimpleList();
}
}