JList won't display properly in JScrollPane
807607Jan 13 2007 — edited Jan 15 2007This is annoying the crap out of me. I've tried everything I can think of. Basically I need to be able to create a JList that can be added to dynamically. I did this and I am able to add to it. When I minimize and restore the window everything displays perfectly. When I first load the application the scrollbar is all screwed up with a horizontal one and no vertical. This occurs regardless of whether I use the policy method to turn off horizontal scrollbar etc. I've tried useing setpreferred size and then revalidate as in the scrollbar2 method but it removes the scroll bars completely. I've tried using container.validate after the adds but that appears to have no effect. Rarely upon first start it will work correctly.
I'm adding a "" element to the list prior to adding it to the scroll pane (although it does it regardless of whether the element is "" or something else). Then I use a method that uses listModel.add(0, str) and calls validate any time something has to be added to the list (has to be reverse order).
Again this works perfectly after i minimize and restore the window but rarely the first time and I have no idea why.