Skip to Main Content

Java SE (Java Platform, Standard Edition)

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!

resizing variable size panel with JScrollPane

843806Mar 13 2008 — edited Mar 18 2008
I have a JPanel which contains four radio buttons. Selecting each of them opens another panel which are of different sizes.
These panels open in the same parent panel below the radio button panel.
However these panels contain large no of components. i.e. the final size of the main panel varies depeding on which button is selected.
I am using a JScrollPane to view them properly.
However, I am facing problem while resizing the main panel. If I mention the preferred size of the JScrollPane, the main panel on maximizing, shows this scrollpane with the size mentioned and does not get maximized as the parent panel.
If I don't mention the scrollpane size, resizing the main panel don't show the scrollbars.

what is the correct way to implement a JScrollpane in this case?
Also can anyone tell me what is the exact deifference between setSize() and setPreferredSize()?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 15 2008
Added on Mar 13 2008
3 comments
309 views