Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JPanel preferredsize help.

807607Oct 24 2006 — edited Oct 24 2006
Folks,

Here is what I did:

I put one JPanel in a JScrollPane, and put this JScrollPane in a JFrame. I set a preferredsize of this JPanel so the scroll bar could be seen.

When the program is running, sometimes it figures out that the set preferredsize is too small so it set a new larger preferredsize and repaint(). Now this is the problem:

The new preferredsize won't show immediately. Just the old new preferredsize shows. But when I resize the JFrame, either minimize or maximize, the new preferredsize was then applied correcly.

My question is, how to apply the new preferredsize immediately? What need I do before repaint() the JPanel? What event fired by JFrame resize can apply the new set preferredsize of its component?

Thanks a lot for help!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 21 2006
Added on Oct 24 2006
6 comments
158 views