summaryrefslogtreecommitdiffstats
path: root/Master/Reference Architectures and Patterns/hjp5/examples/Listing3711.java
diff options
context:
space:
mode:
authorSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
committerSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
commit33613a85afc4b1481367fbe92a17ee59c240250b (patch)
tree670b842326116b376b505ec2263878912fca97e2 /Master/Reference Architectures and Patterns/hjp5/examples/Listing3711.java
downloadStudium-master.tar.gz
Studium-master.tar.bz2
add new repoHEADmaster
Diffstat (limited to 'Master/Reference Architectures and Patterns/hjp5/examples/Listing3711.java')
-rw-r--r--Master/Reference Architectures and Patterns/hjp5/examples/Listing3711.java37
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