/** * Copyright (c): Uwe Schmidt, FH Wedel * * You may study, modify and distribute this source code * FOR NON-COMMERCIAL PURPOSES ONLY. * This copyright message has to remain unchanged. * * Note that this document is provided 'as is', * WITHOUT WARRANTY of any kind either expressed or implied. */ import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JApplet; import javax.swing.JButton; import javax.swing.JScrollPane; import javax.swing.JTextArea; public class ButtonApplet2 extends JApplet { JTextArea t; JScrollPane d; JButton b; public void init () { t = new JTextArea(10,40); d = new JScrollPane(t); b = new JButton("druecke mich"); b.addActionListener(new ButtonPressListener(this)); setLayout(new BorderLayout()); add(d,BorderLayout.CENTER); add(b,BorderLayout.SOUTH); } //-------------------- // die geschachtelte Hilfsklasse static class ButtonPressListener implements ActionListener { ButtonApplet2 a; public ButtonPressListener(ButtonApplet2 a) { this.a = a; } public void actionPerformed(ActionEvent e) { a.t.append("autsch!!!\n"); } } }