1

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?

mKorbel
  • 109,525
  • 20
  • 134
  • 319
hyperion1970
  • 41
  • 1
  • 4
  • 2
    Consider posting an [SSCCE](http://sscce.org) that illustrates the problem. Normally, the behaviour your describe is automatically obtained, so you shouldn't have to do anything. Maybe did you mess up with some LayoutManagers, some min/pref/max size, etc... Hard to say without seeing some code. – Guillaume Polet Aug 03 '12 at 17:57

1 Answers1

1

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

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045