/*
	The program demonstrate the use of vertical box
	It also show how to use Glue, rigid area, & strut
	
*
*/

import javax.swing.*;
import java.awt.event.*;
import java.awt.*; // Needed for Box Layout 

public class BoxVertical extends JFrame
{
	private JPanel panel;
	private JButton accept;
	private JButton exit;
	private JButton show;
	
	public BoxVertical()
	{
		// Sets the title of the window
		
		setTitle("Box Window Vertical");
		
		// Sets the size of the window
		
		setSize(300, 400);
		
		// Sets the action when the window is close
		
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		// Sets the start location of the window
		
		setLocationRelativeTo(null);
		
		// Create vertical box
		
		Box box = Box.createVerticalBox();
		
		// Create three buttons
		
		accept = new JButton("Accept");
		show = new JButton("Show");
		exit = new JButton("Exit");
		
		// Add the button to the box using Strut with a specify pixel
		
		box.add(Box.createVerticalStrut(20));
		box.add(accept);
	
		// Add the button to the box using ridgid area with a specify dimension
		
		box.add(Box.createRigidArea(new Dimension(30, 50)));
		box.add(show);
		
		// Glue the buttons
		
		box.add(Box.createVerticalGlue());
		
		// Add the exit button using a strut with a specify pixel
		
		box.add(exit);
		box.add(Box.createVerticalStrut(20));
		
		// Create a panel
		
		panel = new JPanel();
		
		// Add the box to the panel
		
		panel.add(box);
		
		// Add the panel to the content pane
		
		add(panel);
		
		// Sets the visibility of the window
		
		setVisible(true);
		
	}
	
	public static void main(String[] args)
	{
		new BoxVertical();
	}
	
}