I have stored information in a default List Model and I can add to the model easily enough and that then updates the JList. When I want to remove from the JLISt, it gets removed from the Model; but the Jlist will not update unless i resize the app or minimise it. It throws a arrayOutOfBounds exception -1 >=0. Any ideas, i have tried repaint() or revalidate() and clearing the whole list and adding it in again, but it won't let me clear it in the first place.
Every time u modify DefaultListModel try using JList's setModel() method
eg. DefaultListModel dlm = new DefaultListModel(); JList list= new JList(dlm); //try adding something to dlm; //use setModel() now list.setModel(dlm); //try removing from dlm //now use setModel() again list.setModel(dlm);
this should update the list
if it doesn't work try sending the fragment of code check for indices while removing from the model.
here is the remove element. int listdes = (sampleJList.getSelectedIndex()); sampleModel.removeElementAt(listdes);
When it get remove it just doesn't update the list unless u minimize it. A way round it would be to resize the window slightly, and then resize it back.