Guys, kindly help me how to pass the values of my inputs in my JTextField(ID,LastName,FirstName,Course,Year) into my ArrayList without replacing the existing elements. At the same i'll be using my ArrayList stored values to append in my JTextArea(summary)
////// PALOS TEXTFIELD
List<Form> myList = new ArrayList<Form>();
id = new JTextField(20);
id.addKeyListener(new KeyAdapter()
{
public void keyTyped(KeyEvent ke){
char char1 = ke.getKeyChar();
if((!(Character.isDigit(char1))) && (char1 != '\b') ){
ke.consume();
}
}
});
id.addActionListener(handler);
fname = new JTextField(20);
fname.setFont(new Font("TimesRoman", Font.PLAIN,14));
fname.setHorizontalAlignment(JTextField.CENTER);
fname.setBorder(BorderFactory.createEtchedBorder(3, Color.green, Color.white));
fname.addKeyListener(new KeyAdapter()
{
public void keyTyped(KeyEvent ke){
char char1 = ke.getKeyChar();
if((!(Character.isLetter(char1))) &&
(char1 != '\b') )
{
ke.consume();
}
}
public void keyReleased(KeyEvent e){}
public void keyPressed(KeyEvent e){}
});
fname.addActionListener(handler);
lname = new JTextField(20);
lname.addKeyListener(new KeyAdapter()
{
public void keyTyped(KeyEvent ke){
char char1 = ke.getKeyChar();
if((!(Character.isLetter(char1))) &&
(char1 != '\b') )
{
ke.consume();
}
}
public void keyReleased(KeyEvent e){}
public void keyPressed(KeyEvent e){}
});
lname.addActionListener(handler);
year = new JTextField(20);
year.addKeyListener(new KeyAdapter()
{
public void keyTyped(KeyEvent ke){
char char1 = ke.getKeyChar();
if((!(Character.isDigit(char1))) &&
(char1 != '\b') )
{
ke.consume();
}
}
public void keyReleased(KeyEvent e){}
public void keyPressed(KeyEvent e){}
});
year.addActionListener(handler);
course = new JTextField(20);
course.addKeyListener(new KeyAdapter()
{
public void keyTyped(KeyEvent ke){
char char1 = ke.getKeyChar();
if((!(Character.isLetter(char1))) &&
(char1 != '\b') )
{
ke.consume();
}
}
public void keyReleased(KeyEvent e){}
public void keyPressed(KeyEvent e){}
});
course.addActionListener(handler);
////PALOS BUTTONS
addB = new JButton(namesB[1]);
addB.setHorizontalAlignment(JTextField.CENTER);
addB.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
id.selectAll();
fname.selectAll();
lname.selectAll();
course.selectAll();
year.selectAll();
String textID = id.getSelectedText();
String textFName = fname.getSelectedText();
String textLName = lname.getSelectedText();
String textCourse = course.getSelectedText();
String textYear = year.getSelectedText();
summary.setCaretPosition(summary.getDocument().getLength());
}
});
/////pALOS TEXTAREA
summary = new JTextArea(11,31);
summary.setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 5));
summary.setText("ID" + newtab + "FirstName " + newtab + "LastName" + newtab + "Course" + newtab + "Year" + newline);
summary.setEditable(false);