1

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?

4

2 回答 2

2

不要设置JScrollPane's 内容的首选大小。JScrollPanes改为设置首选大小。

于 2012-03-13T13:09:57.240 回答
0

谢谢。我有同样的问题,首选尺寸(重置为 [0,0])解决了这个问题。

于 2013-03-01T09:10:25.127 回答