blob: 4ce818ab8e348aea84913e4dffa39484fac6fe14 (
plain)
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
|
/* Listing3711.java */
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Listing3711
extends JFrame
{
private static final String[] COLORS = {
"rot", "gr�n", "blau", "gelb"
};
public Listing3711()
{
super("JComboBox");
addWindowListener(new WindowClosingAdapter(true));
Container cp = getContentPane();
for (int i = 1; i <= 2; ++i) {
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 2));
panel.add(new JLabel("Farbe " + i + ":"));
JComboBox combo = new JComboBox(COLORS);
combo.setEditable(i == 1);
panel.add(combo);
cp.add(panel, i == 1 ? BorderLayout.NORTH : BorderLayout.CENTER);
}
}
public static void main(String[] args)
{
Listing3711 frame = new Listing3711();
frame.setLocation(100, 100);
frame.setSize(200, 200);
frame.setVisible(true);
}
}
|