resizing variable size panel with JScrollPane
843806Mar 13 2008 — edited Mar 18 2008I 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()?