Hi everyone
I need help with ActionListener, I have a JFrame which has some JLabels, some TextField, four JButtons, and a JTextArea. I want to add on the JTextArea what i write in the JTextField, so when i click the button Add the text goes to the textarea.
Thanks in advance
COde:
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class AddPersonsData extends JFrame {
public AddPersonsData(){
super("Add Persons Data");
setSize(790,270);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container contentPane = getContentPane();
JPanel panel1 = new JPanel(new FlowLayout());
JButton button1 = new JButton("Load");
panel1.add(button1);
JButton button2 = new JButton("Save");
panel1.add(button2);
JButton button3 = new JButton("Clear");
panel1.add(button3);
JButton button4 = new JButton("Exit");
panel1.add(button4);
contentPane.add("South", panel1);
JPanel panel2 = new JPanel(new GridLayout(7, 2));
panel2.add(new JLabel("First Name", JLabel.RIGHT));
panel2.add(new JTextField(20));
panel2.add(new JLabel("Middle Name",JLabel.RIGHT));
panel2.add(new JTextField(20));
panel2.add(new JLabel("Last Name", JLabel.RIGHT));
panel2.add(new JTextField(20));
panel2.add(new JLabel("Gender", JLabel.RIGHT));
panel2.add(new JTextField(20));
panel2.add(new JLabel("Birth Year", JLabel.RIGHT));
panel2.add(new JTextField(20));
panel2.add(new JLabel("Birth Month", JLabel.RIGHT));
panel2.add(new JTextField(20));
panel2.add(new JLabel("Birth Day", JLabel.RIGHT));
panel2.add(new JTextField(20));
contentPane.add("Center", panel2);
JPanel panel3 = new JPanel();
panel3.add(new JScrollPane(new JTextArea(11, 20)));
contentPane.add("West", panel3);
} //end constructor method
public static void main(
String[] args) {
// perform any initialization
AddPersonsData apd=new AddPersonsData();
apd.setVisible(true);
}
}