How to use multiple Layout Managers in a single form?

27 Sep 2018 / 1 minute to read

It is very simple to use more than one Layout Manager in a single form.

  • Drag-and-drop the FlowLayout Manager from the toolbox onto the form setting it as the Container control.


  • Add Panels as Child controls onto the form. The FlowLayout Manager will automatically layout the Child components as shown below.


  • Drag and drop the GridLayout Manager onto the Panel1 and add Button controls as Child controls. This will be arranged as follows.


  • We can also make Panel2 as the Container control for GridBagLayout Manager. This will arrange it’s Child controls (Buttons) in a single row as shown below.


  • Finally make Panel3 as the Container control for the BorderLayout Manager which will arrange the Child controls (Buttons) as follows.


  • The final output of the application with all the Layout Managers arranged in the above said fashion is shown below.


See Also

Creating a Simple Layout, How to programmatically nest various layouts?