1import java.awt.BorderLayout;
2import java.awt.event.ActionEvent;
3import java.awt.event.ActionListener;
4
5import javax.swing.JApplet;
6import javax.swing.JButton;
7import javax.swing.JScrollPane;
8import javax.swing.JTextArea;
9
10public
11 class ButtonApplet extends JApplet {
12
13 JTextArea t;
14 JScrollPane d;
15 JButton b;
16
17 public
18 void init () {
19 t = new JTextArea(10,40);
20 d = new JScrollPane(t);
21 b = new JButton("druecke mich");
22
23 b.addActionListener(new ButtonPressListener(this));
24
25 setLayout(new BorderLayout());
26 add(d,BorderLayout.CENTER);
27 add(b,BorderLayout.SOUTH);
28 }
29 }
30
31class ButtonPressListener
32 implements ActionListener
33{
34 ButtonApplet a;
35
36 public
37 ButtonPressListener(ButtonApplet a) {
38 this.a = a;
39 }
40
41 public
42 void actionPerformed(ActionEvent e) {
43 a.t.append("autsch!!!\n");
44 }
45}
46
47