Java examples for Swing:FlowLayout
By default, a FlowLayout aligns components in the center of the container.
To change the alignment, use its setAlignment() method or pass the alignment in its constructor.
import java.awt.FlowLayout; public class Main { public static void main(String[] argv) throws Exception { // Set the alignment when you create the layout manager object FlowLayout flowLayout = new FlowLayout(FlowLayout.RIGHT); // Set the alignment after you have created the flow layout manager flowLayout.setAlignment(FlowLayout.RIGHT); } }
The following five constants are defined in the FlowLayout class to represent the five different alignments:
The LEADING alignment may mean either left or right depending on the orientation of the component.