//: c13:TextArea.java
// From 'Thinking in Java, 2nd ed.' by Bruce Eckel
// www.BruceEckel.com. See copyright notice in CopyRight.txt.
// Using the JTextArea control.
// <applet code=TextArea width=275 height=225>
// </applet>
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.util.*;
import com.bruceeckel.swing.*;
import com.bruceeckel.util.*;
public class TextArea extends JApplet {
JButton
b = new JButton("Add Data"),
c = new JButton("Clear Data");
JTextArea t = new JTextArea(5, 20);
public void init() {
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){
t.setText(t.getText()+ "Old Dominion University \n");
}
});
c.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){
t.setText("");
}
});
Container cp = getContentPane();
cp.setLayout(new FlowLayout());
cp.add(new JScrollPane(t));
cp.add(b);
cp.add(c);
}
public static void main(String[] args) {
Console.run(new TextArea(), 275, 225);
}
} ///:~