Java Reference
In-Depth Information
LISTING 10.1
Continued
10: SwingConstants.RIGHT);
11: private JTextField url;
12: private JLabel typeLabel = new JLabel(“Type: “,
13: SwingConstants.RIGHT);
14: private JTextField type;
15:
16: public FeedInfo() {
17: super(“Feed Information”);
18: setSize(400, 105);
19: setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
20: setLookAndFeel();
21: // Site name
22: String response1 = JOptionPane.showInputDialog(null,
23: “Enter the site name:”);
24: name = new JTextField(response1, 20);
25:
26: // Site address
27: String response2 = JOptionPane.showInputDialog(null,
28: “Enter the site address:”);
29: url = new JTextField(response2, 20);
30:
31: // Site type
32: String[] choices = { “Personal”, “Commercial”, “Unknown” };
33: int response3 = JOptionPane.showOptionDialog(null,
34: “What type of site is it?”,
35: “Site Type”,
36: 0,
37: JOptionPane.QUESTION_MESSAGE,
38: null,
39: choices,
40: choices[0]);
41: type = new JTextField(choices[response3], 20);
42:
43: setLayout(new GridLayout(3, 2));
44: add(nameLabel);
45: add(name);
46: add(urlLabel);
47: add(url);
48: add(typeLabel);
49: add(type);
50: setLookAndFeel();
51: setVisible(true);
52: }
53:
54: private void setLookAndFeel() {
55: try {
56: UIManager.setLookAndFeel(
57: UIManager.getSystemLookAndFeelClassName());
58: SwingUtilities.updateComponentTreeUI(this);
10
Search WWH ::




Custom Search