Hi!
I'm trying to change a JList inside a JScrollPane dynamically, using
myList.setListData(someArray);
After this I would expect the JScrollPane to show Scrollbars as needed, but this doesn't happen. Googling the issue was not very helpful. I tried various combinations of the following methods, with little success (basically poking through the api docs):
myScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
myList.validate(); myScrollPane.validate();
myScrollPane.setPreferredSize(Dimension someDimension);
myScrollPane.setViewportView(moduleList);
myScrollPane.setLayout(...);
When using the first method a scrollbar appears, but it doesn't get activated by the model change. I also hooked into the PropertyChangeEvent and validated that the JList fires and event when the model changed. What am I missing here? What method do I have to use to make this work, or even better what property would make this work out of the box?