Posted By:
David_Cole
Posted On:
Saturday, August 25, 2001 09:54 PM
Here is a simple example to demonstrate the above:
import javax.swing.*;
import java.awt.event.*;
import java.awt.BorderLayout;
public class JTextAreaTest
extends JFrame implements ActionListener
{
private JButton theButton;
private JTextArea theTextArea;
private JTextField theTextField;
public JTextAreaTest()
{
super("The Frame");
theButton = new JButton("Add Text");
theButton.addActionListener(this);
theTextField = new JTextField(20);
theTextField.setActionCommand("TheTextField");
theTextField.addActionListener(this);
theTextArea = new JTextArea("",15,30);
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(theButton,BorderLayout.SOUTH);
this.getContentPane().add(theTextField,BorderLayout.CENTER);
this.getContentPane().add(theTextArea,BorderLayout.NORTH);
this.pack();
this.show();
}
public void actionPerformed(ActionEvent ae)
{
String quote = """;
theTextArea.setText(theTextArea.getText()
+ quote + theTextField.getText() + quote );
}
public static void main(String[] args)
{
JTextAreaTest JTextAreaTest = new JTextAreaTest();
}
}