Reputation: 4266
I have a JList
in a JScrollPane
and want the scroll pane to behave like it would not exists (concerning preferredSize
) when the list contains less than 10 items. As soon as the list contains at least 10 items I want the scroll pane to have a preferred size like the list would have with 10 items. How is that possible?
Upvotes: 0
Views: 120
Reputation: 168815
Use JList.setVisibleRowCount(int)
. That will set a preferred height for the list that the scroll pane will attempt to honor.
Upvotes: 2