import java.awt.BorderLayout;
import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;


public class LayoutExample extends JPanel {
	
		public static void main(final String[] args) {
			JFrame frame = new JFrame("Layout Example");
			frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
			frame.setSize(450, 150);
			frame.setLocationRelativeTo(null);
			
	
			LayoutExample panel = new LayoutExample();
			
			frame.setContentPane(panel);
	
			panel.initWidgets();
	
			frame.setVisible(true);
		}
		
		public void initWidgets() {
			this.setLayout(new BorderLayout());
			this.add(new JButton("Button 1"), BorderLayout.NORTH);
			this.add(new JButton("Button 2"), BorderLayout.WEST);
			this.add(new JButton("Button 5"), BorderLayout.EAST);
			this.add(new JButton("Button 6"), BorderLayout.SOUTH);
			JPanel innerPanel = new JPanel();
			innerPanel.setLayout(new GridLayout(2, 2, 5, 5));
			innerPanel.add(new JButton("Button 3"));
			innerPanel.add(new JTextField("Text Field"));
			innerPanel.add(new JLabel());
			innerPanel.add(new JButton("Button 4"));
			
			this.add(innerPanel, BorderLayout.CENTER);
		}
}

