From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- .../hjp5/examples/Listing3711.java | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Master/Reference Architectures and Patterns/hjp5/examples/Listing3711.java (limited to 'Master/Reference Architectures and Patterns/hjp5/examples/Listing3711.java') 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 -- cgit v1.2.3