import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;

public class rodrigoluiz extends JFrame implements ActionListener
{
	JPanel Painel_Norte, Painel_Leste, Painel_Centro, Painel_Sul;
	JPanel Painel_Leste1, Painel_Leste2, Painel_Leste3;
	JPanel Painel_Centro1, Painel_Centro2, Painel_Centro3;
	JTextField tf_numero1;
	JTextField tf_numero2;
	JTextField tf_resultado;
	JButton bt_adicionar, bt_limpar, bt_sair;

	 public rodrigoluiz()
    {
    		getContentPane().setLayout(new BorderLayout());
    		getContentPane().add("North", Painel_Norte = new JPanel (new FlowLayout(FlowLayout.LEFT)));
    		Painel_Norte.add(new JLabel("Adicionar Número"));
    		getContentPane().add("West", Painel_Leste = new JPanel(new GridLayout(3, 1)));
    		Painel_Leste.add(Painel_Leste1 = new JPanel(new FlowLayout(FlowLayout.RIGHT)));
    		Painel_Leste1.add(new JLabel ("Primeiro Número:"));
    		Painel_Leste.add(Painel_Leste2 = new JPanel(new FlowLayout(FlowLayout.RIGHT)));
    		Painel_Leste2.add(new JLabel ("Segundo Número:"));
    		Painel_Leste.add(Painel_Leste3 = new JPanel(new FlowLayout(FlowLayout.RIGHT)));
    		Painel_Leste3.add(new JLabel ("Resultado:"));

    		getContentPane().add("Center", Painel_Centro= new JPanel(new GridLayout(3, 1)));
			Painel_Centro.add(Painel_Centro1 = new JPanel(new FlowLayout(FlowLayout.CENTER)));
    		Painel_Centro1.add(tf_numero1 = new JTextField(20));
    		Painel_Centro.add(Painel_Centro2 = new JPanel(new FlowLayout(FlowLayout.CENTER)));
			Painel_Centro2.add(tf_numero2 = new JTextField(20));
			Painel_Centro.add(Painel_Centro3 = new JPanel(new FlowLayout(FlowLayout.CENTER)));
			Painel_Centro3.add(tf_resultado = new JTextField(20));

			getContentPane().add("South", Painel_Sul = new JPanel(new FlowLayout(FlowLayout.CENTER)));
    		Painel_Sul.add(bt_adicionar = new JButton ("Adicionar"));
    		Painel_Sul.add(bt_limpar = new JButton ("Limpar"));
    		bt_adicionar.addActionListener(this);
			bt_limpar.addActionListener(this);
			

			setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    		setResizable(false);
    		pack();
    		setVisible(true);
    		
    		
    		getContentPane().add("South", Painel_Sul = new JPanel(new FlowLayout(FlowLayout.RIGHT)));
    		Painel_Sul.add(bt_sair = new JButton ("Sair"));
    		bt_sair.addActionListener(this);
    }
    		
    		
    public static void main (String args [])
    {
    		new rodrigoluiz();
    }
    public void actionPerformed(ActionEvent evento)
    {
    	if(evento.getSource()==bt_adicionar)
    	{
    		double Valor1 = Double.parseDouble(tf_numero1.getText());
    		double Valor2 = Double.parseDouble(tf_numero2.getText());
    		double Resultado = Valor1 + Valor2;
    		tf_resultado.setText(""+Resultado);
    	}
    	if(evento.getSource()==bt_limpar)
    	{
    		 tf_numero1.setText("");
    		 tf_numero2.setText("");
 
    		tf_resultado.setText("");
    	}
    	if(evento.getSource()==bt_sair)
    	{
    		System.exit(0);
    	}

    	
    }
}