/** * 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 ButtonApplet 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); } } class ButtonPressListener implements ActionListener { ButtonApplet a; public ButtonPressListener(ButtonApplet a) { this.a = a; } public void actionPerformed(ActionEvent e) { a.t.append("autsch!!!\n"); } } //--------------------