I'm having trouble figuring this out. I have 3 jlists and each one has a textbox and a "add" button so the user can enter text to be added to the list. I have read probably a dozen webpages or forum posts on this and all have pretty much the same code advice for doing this. The problem I'm having is that none have said or shown how the code actually links the button to the jlist1, jlist2, and jlist3 respectively. What am I missing?? Here is the code I have and not sure what to change or add.
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String addName = (jTextField1.getText());
names = new DefaultListModel();
names.addElement(addName);
nameList = new JList(names);
jTextField1.setText("");
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
String addPlace = (jTextField2.getText());
places = new DefaultListModel();
places.addElement(addPlace);
placeList = new JList(places);
jTextField2.setText("");
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
String addDay = (jTextField3.getText());
days = new DefaultListModel();
days.addElement(addDay);
dayList = new JList(days);
jTextField3.setText("");
}
Thanks