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
Constructor of BoxLayout class
Example of BoxLayout class with Y-AXIS:
Example of BoxLayout class with X-AXIS