Documentation

Layout Managers

Layout managers are an essential part of Swing forms. They lay out components within a container. JFormDesigner provides support for following layout managers:

How to choose a layout manager?

For "normal" forms use either one of the grid-based layout managers (MigLayout, FormLayout, TableLayout or GridBagLayout) or use "Free Design" (GroupLayout). Each layout manager has its advantages and disadvantages. MigLayout, FormLayout and TableLayout are open source and require that you ship an additional library with your application.

  • MigLayout has most features (units, alignment, grouping, docking, flowing, in-cell flow and more).
  • FormLayout has many features (dialog units, column/row alignment, column/row grouping), but may have problems if a component spans multiple columns or rows and can not handle right-to-left component orientation.
  • TableLayout does not have these limitations, but has fewer features than FormLayout.
  • GridBagLayout is the weakest of these four grid-based layout managers, but JFormDesigner hides its complexity and adds additional features like gaps. Use GridBagLayout if you cannot use MigLayout, FormLayout or TableLayout.
  • GroupLayout (Free Design) allows you to lay out your forms by simply placing components where you want them. Visual guidelines suggest optimal spacing, alignment and resizing of components.

For button bars use MigLayout, FormLayout, TableLayout, GridBagLayout or FlowLayout.

To layout a main window, use BorderLayout. Place the toolbar to the north, the status bar to the south and the content to the center.

For toolbars use JToolBar, which has its own layout manager (based on BoxLayout).

For radio button groups, BoxLayout may be a good choice. Mainly because JRadioButton has a gap between its text and its border and therefore the gaps provided by FormLayout, TableLayout and GridBagLayout are not necessary.

Change layout manager

You can change the layout manager at any time. Either in the Properties view or by right-clicking on a container in the Design or Structure view and selecting the new layout manager from the popup menu.

Change Layout Properties Change Layout Popup