import java.awt.*; import java.awt.event.*; public class Fenster extends Frame implements ActionListener { Button b1, b2; public Fenster() { super("Mein Fenster"); b1 =new Button ("Die Eins"); b2 =new Button ("Die Zwei"); setLayout (new BorderLayout()); add(b1, BorderLayout.SOUTH); add(b2, BorderLayout.CENTER); b1.addActionListener(this); b2.addActionListener(this); pack(); } public void actionPerformed(ActionEvent e) { if (e.getSource() == b1) System.out.println("Die Action is los am Knopf 1!"); else System.out.println("Die Action is los am Knopf 2!"); } public static void main(String[] args) { Fenster w = new Fenster(); w.setVisible(true); } }