/**
 *Dsenvolvido pelo prof. André Aparecido da Silva
 *para as aulas 19, 20  e 21 da disciplina de linguagem de programação
 */
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;


public class Calcula_Exponencial extends JFrame implements ActionListener 
{
	JPanel Painel_Norte, Painel_Oeste, Painel_Leste, Painel_Centro, Painel_Sul;
	JPanel Painel_Oeste1, Painel_Oeste2, Painel_Oeste3;
	JPanel Painel_Centro1, Painel_Centro2, Painel_Centro3;
	JTextField tf_Numero, tf_Potencia, tf_Resultado;
	JButton bt_Calcular, bt_Limpar, bt_Sair; 
	  
    public Calcula_Exponencial() 
    {
    		getContentPane().setLayout(new BorderLayout());
    		getContentPane().add("North", Painel_Norte = new JPanel (new FlowLayout(FlowLayout.CENTER)));
    		Painel_Norte.add(new JLabel("CALCULA EXPONENCIAIS"));
    		//////////////////////////////////////////////////////////////////
    		getContentPane().add("West", Painel_Oeste = new JPanel(new GridLayout(3, 1)));
    		Painel_Oeste.add(Painel_Oeste1 = new JPanel(new FlowLayout(FlowLayout.RIGHT)));
    		Painel_Oeste1.add(new JLabel ("NUMERO:"));
    		Painel_Oeste.add(Painel_Oeste2 = new JPanel(new FlowLayout(FlowLayout.RIGHT)));
    		Painel_Oeste2.add(new JLabel ("POTÊNCIA:"));
    		Painel_Oeste.add(Painel_Oeste3 = new JPanel(new FlowLayout(FlowLayout.RIGHT)));
    		Painel_Oeste3.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.LEFT)));
    		Painel_Centro1.add(tf_Numero = new JTextField(15));
			Painel_Centro.add(Painel_Centro2 = new JPanel(new FlowLayout(FlowLayout.LEFT)));
			Painel_Centro2.add(tf_Potencia   = new JTextField(15));
			Painel_Centro.add(Painel_Centro3 = new JPanel(new FlowLayout(FlowLayout.LEFT)));
    		Painel_Centro3.add(tf_Resultado   = new JTextField(15));
    		tf_Resultado.setEditable(false);  
    		///////////////////////////////////////////////////////////////////
    		getContentPane().add("South", Painel_Sul = new JPanel(new FlowLayout(FlowLayout.CENTER)));
    		Painel_Sul.add(bt_Calcular = new JButton ("CALCULAR"));
    		Painel_Sul.add(bt_Limpar = new JButton ("LIMPAR"));
    		Painel_Sul.add(bt_Sair = new JButton ("SAIR DO SISTEMA")); 	
    		//Painel_Sul.setBackground(Color.orange);	
    		///////////////////////////////////////////////////////////////////
			bt_Calcular.addActionListener(this);
			bt_Limpar.addActionListener(this);
    		bt_Sair.addActionListener(this); 	
    			
    		///////////////////////////////////////////////////////////////////		
    		setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    		setResizable(false);
    		pack();
    		setVisible(true);
    		   	
    }
    public static void main (String args [])
    {
    		new Calcula_Exponencial();
    }
    public void actionPerformed(ActionEvent e)
    {
    		if(e.getSource()==bt_Calcular)
    		{	
    			
    			double Numero = Double.parseDouble(tf_Numero.getText());
    			double Potencia = Double.parseDouble(tf_Potencia.getText());
    			if ((Numero==0)||(Potencia==0))
    		    	{tf_Resultado.setText("Digite valores válidos");}	
	    	    else
    	    	{
    	    		double Resultado = Math.pow(Numero, Potencia);
    	    		tf_Resultado.setText(""+Resultado);
    	    	}		  
    			
    		}	
			if(e.getSource()==bt_Limpar)
			{
				tf_Numero.setText(" ");
    			tf_Potencia.setText(" ");
    			tf_Resultado.setText(" ");
				
			}	
    		if(e.getSource()==bt_Sair)
    		{System.exit(0);}	    	
    }	
    	
    
    
}