I have a JList in my Java Swing application and when a user clicks a button, the list clears and the contents reset as follows:
public void reset(ArrayList<String> content) {
listModel.removeAllElements();
System.out.println(content.size());
for(int i = 0; i < content.size(); i++) {
listModel.addElement(content.get(i));
System.out.println("Added element " + content.get(i));
}
}
The list is initialized as follows
listModel = new DefaultListModel();
list = new JList(listModel);
However there is a problem. The list clears (before the reset, there was other content. This content does go away), but the new content does not show up. And, from the output, I can see that 6 elements have been added. But they do not show up in the list. Why is this?
nobody knows, only Concurency in Swing could be issue, be sure that all events would be dode on EDT, otherwise for better help sooner post an SSCCE, for example
EDIT
added String instances requested by @Robin
with rendering JPanel inside JScrollPane requested by @trashgod