Hi everyone,
I have an array list which populates a JList from my database. When I insert a new entry into my database it will update my JList correctly with that new entry.
However, when I delete or update from my database I can only get my JList to display all my records twice except for the ones I either updated or deleted.
What I need to know is how to clear my JList without getting a nullPointer Exception and refill my JList with the new updated data...
I'll show you how I populate my JList after I make an insert into the database....
((AddPanel) tab2).addInsertActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
data_model.insert(((AddPanel) tab2).getSubject(), ((AddPanel) tab2).getMessage());
DefaultListModel list_model = ((DisplayPanel) tab1).getListModel();
for (ListElement elt : data_model.getElementList()) {
if (! list_model.contains(elt)){
list_model.addElement(elt);
System.out.println(">>Inserted new message: " + elt.getSubject());
}
}
}
});
Any help would be appreciated!
Thanks in advance