go to previous page   go to home page   go to next page

Answer:

Yes.

Nested Panels

frame with 6 text fields

JPanels are both components and containers. As a component they can be placed inside containers (such as JPanel) and as a container they can contain other JPanels. Each panel has its own layout manager which may be any of several types. This example uses FlowLayout for all panels.

nested panels

The illustration above shows how each label and text field pair has been placed into its own panel (shown with dotted lines), and how those panels have been placed into two other panels (shown with solid lines). Then those two panels have beed added to the frame. The size of the frame was set so that the layout looks nice.

QUESTION 10:

Was it necessary to use the two panels that contain panels for this layout?