import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.util.*; import java.io.*; public class Bsp1_Mediator extends JFrame implements ActionListener { public Bsp1_Mediator() { setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); setGUI(); } private JButton createButton(String caption, String command) { JButton bn = new JButton(caption); bn.setFont( new Font("Arial", Font.BOLD,16) ); bn.setActionCommand(command); bn.addActionListener(this); return bn; } private void setGUI() { setSize(800, 630); setLocation(20,20); setTitle("Test Mediator, 2. Beispiel"); JPanel pnButton = new JPanel(); pnButton.setLayout( new FlowLayout() ); pnButton.add( createButton("Chatten","chatten") ); pnButton.add( createButton("Abbruch","Abbruch") ); this.getContentPane().setLayout( new BorderLayout() ); JTextArea editor = Editor.getInstance(); this.getContentPane().add( new JScrollPane(editor), BorderLayout.CENTER); this.getContentPane().add( pnButton, BorderLayout.SOUTH ); } // setGUI public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if (cmd.equals("chatten") ) { test1(); } if (cmd.equals("Abbruch") ) { setVisible(false); dispose(); // System.exit(0); } } private void test1() { } public static void main(String[] args) { Bsp1_Mediator frame = new Bsp1_Mediator(); frame.setVisible(true); } } // Bsp1_Mediator