import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;

public class Demonstra_GridLayout extends JFrame implements ActionListener  
{
		JPanel Painel1, Painel2, Painel3, Painel4;
		JButton bt_Sair; 
		public Demonstra_GridLayout()
		{
				setLayout(new GridLayout(2, 1));
				getContentPane().add(Painel1 = new JPanel(new FlowLayout(FlowLayout.CENTER)));
				Painel1.setBackground(Color.lightGray);
				Painel1.add(new JLabel("PAINEL 1"));
				getContentPane().add(Painel2 = new JPanel(new GridLayout(1, 2)));
				Painel2.add(Painel3 = new JPanel());
				Painel2.add(Painel4 = new JPanel());
				Painel3.add(new JLabel("PAINEL 3"));
				Painel2.add(Painel4 = new JPanel()); 
				Painel4.add(new JLabel("PAINEL 4"));
				Painel4.add(bt_Sair = new JButton ("SAIR DO SISTEMA"));
				setSize(500, 600);
				//pack();
				setVisible(true);		
		}	
		public static void main(String[] args)
				{new Demonstra_GridLayout();}
    	public void actionPerformed(ActionEvent e)
    	{
    			if(e.getSource()==bt_Sair)
    				{System.exit(0);}	
    	}	 		
 }