I have a JScrollPane containing a JPanel to which I insert JLabels
dynamically at run time. i.e. the user presses a button and a new label
is added to the JPanel.
The labels are added row after row until there is no more visual room.
What you expect is that on the next new line, the JPanel will grow vertically,
and the JScrollPane show it's vertical scrollbar so one can scroll up and down
the new, bigger JPanel. Alas, for some reason, the JPanel doesn't grow beyond
the size of the JScrollPane.
PLEASE!!! How can I make the JPanel grow dynamicaly?
Thanks in advance,
Gadi N.
The trick is that you must programmatically determine what the size of your
JPanel should be so that all your graphical objects (labels in your case)
should fit in nicely. Then you should call the method setPreferredSize on
your JPanel object with the dimensions that you calculated.
Furthermore this dimension should obviously be larger than the dimension of
your JScrollPane otherwise the scrolllbars will have no reason to appear. I
also set a Preferred size for my JScrollPane
Let me know if by any chance this still does not work for you. It took me
too long to figure this one out.
regards
Henko
email: gou...@telkomsa.net
"Gadi N" <n_g...@hotmail.com> wrote in message
news:c56a8be7.03062...@posting.google.com...