diff options
Diffstat (limited to 'Master/Reference Architectures and Patterns/hjp5/examples/Listing3711.java')
| -rw-r--r-- | Master/Reference Architectures and Patterns/hjp5/examples/Listing3711.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Master/Reference Architectures and Patterns/hjp5/examples/Listing3711.java b/Master/Reference Architectures and Patterns/hjp5/examples/Listing3711.java new file mode 100644 index 0000000..4ce818a --- /dev/null +++ b/Master/Reference Architectures and Patterns/hjp5/examples/Listing3711.java @@ -0,0 +1,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);
+ }
+}
\ No newline at end of file |
