import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Fenster4 implements ActionListener { public static void main(String[] aaa) { new Fenster4("Eins"); new Fenster4("Zwei"); } private String name; public Fenster4(String titel) { JFrame f = new JFrame(titel); name=titel; JTextArea textfeld = new JTextArea("Es war einmal..."); // Toolbar bauen JPanel toolbar = new JPanel(); toolbar.setLayout(new FlowLayout(FlowLayout.LEFT)); toolbar.add(new LoadButton(textfeld)); toolbar.add(new JButton("Save")); JButton ende = new JButton("Exit"); toolbar.add(ende); ende.addActionListener( this ); // StatusZeile bauen JLabel status = new JLabel ("Melde: "+name+" in Ordnung."); Container c = f.getContentPane(); c.setLayout (new BorderLayout()); c.add(toolbar, BorderLayout.NORTH); c.add(status, BorderLayout.SOUTH); JScrollPane textPane = new JScrollPane(textfeld); c.add(textPane, BorderLayout.CENTER); f.pack(); f.setVisible(true); } public void actionPerformed(ActionEvent e) { System.out.println("Beende mich auf Benutzer-Wunsch im Fenster "+name); System.exit(0); } }