/**
 *Criado pelo prof. André Aparecido da Silva para as aulas 22a 24 
 *do Curso Tecnico em Informática do Colégio Estadual Maria Aguiar Teixeira 
 *
 */
import javax.swing.*;
import java.awt.*;
import javax.swing.event.*;
import java.awt.event.*;

public class TelaExecutaFuncao extends JFrame implements ActionListener
{
        JPanel Painel_Sul, Painel_Leste, Painel_Oeste, Panel_Centro, Painel_Norte, Painel_Resultados, Painel_Botoes; 
        JTextField tf_Funcao; 
       	JLabel lbl_Resultados = new JLabel(); 	
       
        JButton bt_Sair, bt_Limpar, bt_Executar;
       
        int Resultados = 0;		 
		public TelaExecutaFuncao() 
    	{		getContentPane().setLayout(new BorderLayout());
    			getContentPane().add("East", Painel_Leste = new JPanel());
    			getContentPane().add("West", Painel_Oeste = new JPanel(new FlowLayout(FlowLayout.RIGHT)));
    			Painel_Oeste.add(new JLabel("f(x) = "));
    			getContentPane().add("Center", Panel_Centro = new JPanel());
    			Panel_Centro.add(tf_Funcao  = new JTextField(20));
    			getContentPane().add("North", Painel_Norte = new JPanel()); 	
    			getContentPane().add("South", Painel_Sul = new JPanel(new GridLayout(2, 1)));
    			Painel_Sul.add(Painel_Resultados = new JPanel());
    			Painel_Resultados.add( new JLabel("RESULTADO:"));
    			Painel_Sul.add(Painel_Botoes  = new JPanel());	
    			
    			Painel_Botoes.add(bt_Executar = new JButton ("EXECUTAR"));
    			Painel_Botoes.add(bt_Limpar = new JButton ("LIMPAR"));
    			Painel_Botoes.add(bt_Sair = new JButton ("SAIR"));
    			
    			bt_Limpar.addActionListener(this);
    			bt_Executar.addActionListener(this);
        		bt_Sair.addActionListener(this);
        		bt_Executar.addActionListener(this);
    			
    			pack();
    			setResizable(false);
    			setVisible(true);	
    	}
    	public void actionPerformed(ActionEvent e)
    	{
    			if(e.getSource()==bt_Sair)
    					{System.exit(0);}
    				
    			if(e.getSource()==bt_Limpar)
    			{
	   					lbl_Resultados.setText(">>>>"+Resultados);
    					System.out.println(""+Resultados);
    			}	
    			if(e.getSource()==bt_Executar)
    			{		System.out.println("SSSSSSSSSSSSSSSSSSSSS"+Resultados);  
						Resultados = Integer.parseInt(tf_Funcao.getText());
    					lbl_Resultados.setText(">>>>"+Resultados);
    					System.out.println("SSSSSSSSSSSSSSSSSSSSS"+Resultados);  				
		    	}
    	}
				   		
    	public static void main(String args [])
    	{
    			new TelaExecutaFuncao();
    	}	
    
    
}