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 ButtonApplet2 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
31
32 static
33 class ButtonPressListener
34 implements ActionListener {
35 ButtonApplet2 a;
36
37 public
38 ButtonPressListener(ButtonApplet2 a) {
39 this.a = a;
40 }
41
42 public
43 void actionPerformed(ActionEvent e) {
44 a.t.append("autsch!!!\n");
45 }
46 }
47 }