Thread: JFrame question
View Single Post
  #2 (permalink)  
Old 10-11-2007, 11:44 AM
hardwired hardwired is offline
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
Transferring data from the deposit JTextField to the deposit list.
For each entry into the deposit textField (depositField), press the "ok" button and in the listener for the "ok" button you add the depositField entry to the list:
Code:
public void actionPerformed(ActionEvent e) { String text = depositField.getText(); DefaultListModel model = (DefaultListModel)list.getModel(); model.addElement(text); depositField.setText(""); }
To be able to make changes to the list you will need to use a DefaultListModel.
Code:
JList list = new JList(new DefaultListModel());
Reply With Quote