import java.awt.*; import java.awt.event.*; /** Musterloesung für AWT - Aufgabe @author Tom Eicher www.teicher.net */ public class FensterLoesung extends Frame implements ActionListener { Button b1, b2; Label l; public FensterLoesung() { super("Mein Fenster"); b1 =new Button ("Die Eins"); b2 =new Button ("Die Zwei"); l = new Label ("Drück was!!!"); setLayout (new BorderLayout()); add(b1, BorderLayout.EAST); add(b2, BorderLayout.WEST); add(l, BorderLayout.CENTER); b1.addActionListener(this); b2.addActionListener(this); pack(); } public void actionPerformed(ActionEvent e) { if (e.getSource() == b1) { l.setText("1"); l.setBackground(Color.RED); } else { l.setText("2"); l.setBackground(Color.GREEN); } } public static void main(String[] args) { FensterLoesung w = new FensterLoesung(); w.setVisible(true); } }