Javatpoint Logo
Javatpoint Logo

Java BoxLayout

The BoxLayout is used to arrange the components either vertically or horizontally. For this purpose, BoxLayout provides four constants. They are as follows:

Note: BoxLayout class is found in javax.swing package.

Fields of BoxLayout class

  1. public static final int X_AXIS
  2. public static final int Y_AXIS
  3. public static final int LINE_AXIS
  4. public static final int PAGE_AXIS

Constructor of BoxLayout class

  1. BoxLayout(Container c, int axis): creates a box layout that arranges the components with the given axis.

Example of BoxLayout class with Y-AXIS:

BoxLayout class

Example of BoxLayout class with X-AXIS

BoxLayout class example
Next TopicCardLayout




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


B.Tech / MCA