Resizing JPanel within JScrollPane

M

McMatt

Hello,

how can the size of a JPanel automatically be calculated?

The panel which is scrollable in the scrollpane has always the height
which I set with setPreferredSize(Dimension). If the components on
that panel need less place it should be smaller so that the scroll
bars can disappear if not necessary. And if the components on that
panel need more space it should be larger so that one can see all of
the stuff when scrolling down.

I hope the description is exact enough.

Thanks for any help in advance.

Matthias
 
M

McMatt

Hello,

thanks for the quick reply. During the preparation of a SSCCE it
turned out that more elements are involved in it than expected.

The main reason was a layout in on of the components.

But I needed still a validate() call - namely scrollPane.validate().

Thanks for your help,
Kind regards,

Matthias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top