Java Swing FlowLayout

FlowLayout is the simplest layout in Java Swing layouts. The FlowLayout places components from left to right in a row using preferred component sizes until no space is available in the container. When no space is available, a new row is started. The placement of the component depends on the size of the container, therefore, you cannot guarantee which row the component is placed.

The FlowLayout is useful as a pad for a single component to make sure that the component will be placed at the center area of a container. Notice that FlowLayout is default layout of JPanel container.

Here is the screenshot of FlowLayout demo application:

Java FlowLayout

  • Was this tutorial helpful ?
  • YesNo