import java.awt.*;
import javax.swing.*;

public class BoxPanel extends JPanel
{
	//Sets up a JPanel with Buttons

	public BoxPanel()
	{
		//sets the layout to a Box layout where the layout is top to bottom(Y_AXIS)
		setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));

		//sets the background color (JComponent)
		setBackground(Color.red);

		//creates buttons with text
		JButton btn1 = new JButton("Button 1");
		JButton btn2 = new JButton("Button 2");
		JButton btn3 = new JButton("Button 3");
		JButton btn4 = new JButton("Button 4");
		JButton btn5 = new JButton("Button 5");

		//Appends btn1 component to the end of this container.
		add(btn1);

		//Creates an invisible component that's always the specified size
		//and adds it to the container
		add(Box.createRigidArea(new Dimension(0,10)));

		//Appends btn2 component to the end of this container.
		add(btn2);

		//Creates a vertical glue component and adds it to the container
		add(Box.createVerticalGlue());

		//Appends btn3 and btn4 components to the end of this container.
		add(btn3);
		add(btn4);

		//Creates an invisible component that's always the specified size
		//and adds it to the container.
		add(Box.createRigidArea(new Dimension(0,20)));

		//Appends btn5 component to the end of this container.
		add(btn5);
	}
}