Refresh A JList With A Model
Hello, I am having a bit of a problem. I have created a JList and set it up with a model, and what I need it to do is whenever I hit a specific button it reloads itself. basically I have a class that gets all the subdirectories in a directory and stores it in an array. When I hit this button it creates a new folder so, I need it to then update the JList.
I have tried a few things, but this is the only one I can remember
Code:
model.removeAllElements();
new MultiList();
for(int i = 0; i < l.list.length; i++){
model.addElement(l.list[i]);
}
Re: Refresh A JList With A Model
Your code seems reasonable, but I have no idea what new MultiList() does, I hope you don't create a new JList because that defeats the purpose of updating the model.
Post your Short, Self Contained, Correct Example that demonstrates the problem.