I have a couple of Jlist within jscrollpanes in a gridbaglayout. The amount of entries in 1 Jlist is more than fits in the visible area of the Jlist. But the jscrollpane does not provide scrolling functionality.
I used to have the all of the jscrollpanes enclosed in a jpanel, at that time scrollpane provided the correct scrolling functionality.
I have the preferredsize of the Jlist set to [0,0]. The layout of the Jlist is correct. I can set the preferredsize of the JList to an explicit value of for example [80,300]. This causes JList to be scrollable partially. The real size of the JLIst, if it would be visible completely, is much longer.
Somehow I guess the gridbaglayout is resizing my Jlist in a way that the Jlist is not able to provide the correct size it has to the scrollpane.
How do I make the gridbaglayout and Jlist within jscrollpanes work together?
Don't set preferred sizes of JScrollPane
's content. Set preferred size for the JScrollPanes
instead.