hyperion1970
hyperion1970

Reputation: 41

How do I set a JScrollPane to a fixed Maximum size around a JList

My program creates a series of JScrollPanes each containing a JList. The JList displays vertically and each one has a fixed number of lines. The initial size of the container they are in isn't big enough to display the complete JList, thus the scrollpane, but can be resized.

I want each JScrollPane to stop growing when it reaches a size sufficient to display the complete JList.

I've tried setting the JList SetVisibileRowCount and then setting the ScrollPane's MaximumSize to the MaximumSize of the JList, but it seems to have no affect.

Any suggestions?

Upvotes: 1

Views: 6904

Answers (1)

trashgod
trashgod

Reputation: 205875

This example shows one approach: It invokes setVisibleRowCount() dynamically to limit the maximum size. It may help you construct an sscce.

Upvotes: 1

Related Questions