Calculadora Java Quase 100%

Estou Iniciando na programação em Java e gostaria de uma ajuda. Estou fazendo uma calculadora no Netbeans 6.8.

[b] - Criei um novo Projeto;

  • Adicionei um JFrame;
  • Fui modificando o código(eventos do botão);[/b]

O modo que estou fazendo está Correto?

As operações estão ok, o único problema é o botão igual (bIgual), pois não sei como implementa-lo…
Segue abaixo o código do JFrame…

[code]package Frames;

public class InterfaceCalc extends javax.swing.JFrame {

public InterfaceCalc() {
    initComponents();
}

String Digitos = “”;
String Adds;
Boolean flag = true;
double Convertido1 = 0, Convertido2 = 0, Resultado;
String ResultadoString;

@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">                          
private void initComponents() {

    jToggleButton1 = new javax.swing.JToggleButton();
    bNro1 = new javax.swing.JButton();
    bNro3 = new javax.swing.JButton();
    bNro2 = new javax.swing.JButton();
    bSubtracao = new javax.swing.JButton();
    bNro4 = new javax.swing.JButton();
    bNro5 = new javax.swing.JButton();
    bNro6 = new javax.swing.JButton();
    bMultiplicacao = new javax.swing.JButton();
    bNro7 = new javax.swing.JButton();
    bNro8 = new javax.swing.JButton();
    bNro9 = new javax.swing.JButton();
    bDivisao = new javax.swing.JButton();
    bVirgula = new javax.swing.JButton();
    bNro0 = new javax.swing.JButton();
    bSoma = new javax.swing.JButton();
    bIgual = new javax.swing.JButton();
    lDisplay = new javax.swing.JLabel();
    bC = new javax.swing.JButton();

    jToggleButton1.setText("jToggleButton1");

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

    bNro1.setText("1");
    bNro1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            bNro1ActionPerformed(evt);
        }
    });

    bNro3.setText("3");
    bNro3.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            bNro3ActionPerformed(evt);
        }
    });

    bNro2.setText("2");
    bNro2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            bNro2ActionPerformed(evt);
        }
    });

    bSubtracao.setText("-");
    bSubtracao.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            bSubtracaoActionPerformed(evt);
        }
    });

    bNro4.setText("4");
    bNro4.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            bNro4ActionPerformed(evt);
        }
    });

    bNro5.setText("5");
    bNro5.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            bNro5ActionPerformed(evt);
        }
    });

    bNro6.setText("6");
    bNro6.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            bNro6ActionPerformed(evt);
        }
    });

    bMultiplicacao.setText("*");
    bMultiplicacao.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            bMultiplicacaoActionPerformed(evt);
        }
    });

    bNro7.setText("7");
    bNro7.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            bNro7ActionPerformed(evt);
        }
    });

    bNro8.setText("8");
    bNro8.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            bNro8ActionPerformed(evt);
        }
    });

    bNro9.setText("9");
    bNro9.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            bNro9ActionPerformed(evt);
        }
    });

    bDivisao.setText("/");
    bDivisao.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            bDivisaoActionPerformed(evt);
        }
    });

    bVirgula.setText(",");
    bVirgula.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            bVirgulaActionPerformed(evt);
        }
    });

    bNro0.setText("0");
    bNro0.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            bNro0ActionPerformed(evt);
        }
    });

    bSoma.setText("+");
    bSoma.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            bSomaActionPerformed(evt);
        }
    });

    bIgual.setText("=");
    bIgual.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            bIgualActionPerformed(evt);
        }
    });

    lDisplay.setBackground(new java.awt.Color(255, 255, 255));
    lDisplay.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
    lDisplay.setBorder(javax.swing.BorderFactory.createEtchedBorder());

    bC.setText("C");
    bC.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            bCActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                .addComponent(lDisplay, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE)
                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(bNro0, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                    .addComponent(bNro1)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(bNro2)))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(bNro3)
                                .addComponent(bVirgula, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addComponent(bNro4)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(bNro5)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(bNro6)))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(bIgual, javax.swing.GroupLayout.DEFAULT_SIZE, 41, Short.MAX_VALUE))
                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(bNro7)
                        .addComponent(bC, javax.swing.GroupLayout.DEFAULT_SIZE, 39, Short.MAX_VALUE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(bDivisao, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(bNro8))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(bMultiplicacao, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(bNro9))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(bSubtracao, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(bSoma, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE))))
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(lDisplay, javax.swing.GroupLayout.DEFAULT_SIZE, 50, Short.MAX_VALUE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bMultiplicacao, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(bSubtracao, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bDivisao, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(bC, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(bNro7, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(bNro8, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(bNro9, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(bSoma, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                .addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(bNro4, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(bNro5, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(bNro6, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(bNro1, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(bNro2, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(bNro3, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(bNro0, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(bVirgula, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addComponent(bIgual, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addContainerGap())
    );

    pack();
}// </editor-fold>                        

private void bNro1ActionPerformed(java.awt.event.ActionEvent evt) {                                      
    Adds = "1";
    Digitos += Adds;
    lDisplay.setText(Digitos);        
}                                     

private void bNro3ActionPerformed(java.awt.event.ActionEvent evt) {                                      
    Adds = "3";
    Digitos += Adds;
    lDisplay.setText(Digitos);
}                                     

private void bNro2ActionPerformed(java.awt.event.ActionEvent evt) {                                      
    Adds = "2";
    Digitos += Adds;
    lDisplay.setText(Digitos);
}                                     

private void bSubtracaoActionPerformed(java.awt.event.ActionEvent evt) {                                           
    if(flag == true){
        Convertido1 = Double.parseDouble(Digitos);
        Digitos = "";
        Resultado = Convertido1 - Convertido2;
        ResultadoString = String.valueOf(Resultado);
        lDisplay.setText(ResultadoString);
        flag = false;
    }else{
        Convertido2 = Double.parseDouble(Digitos);
        Digitos = "";
        Resultado = Convertido1 - Convertido2;
        Convertido1 = 0;
        ResultadoString = String.valueOf(Resultado);
        lDisplay.setText(ResultadoString);
        Convertido2 = Resultado;
        flag = true;
    }
}                                          

private void bNro4ActionPerformed(java.awt.event.ActionEvent evt) {                                      
    Adds = "4";
    Digitos += Adds;
    lDisplay.setText(Digitos);
}                                     

private void bNro5ActionPerformed(java.awt.event.ActionEvent evt) {                                      
    Adds = "5";
    Digitos += Adds;
    lDisplay.setText(Digitos);
}                                     

private void bNro6ActionPerformed(java.awt.event.ActionEvent evt) {                                      
    Adds = "6";
    Digitos += Adds;
    lDisplay.setText(Digitos);
}                                     

private void bMultiplicacaoActionPerformed(java.awt.event.ActionEvent evt) {                                               
    if(flag == true){
        Convertido1 = Double.parseDouble(Digitos);
        Digitos = "";
        Resultado = Convertido1 * Convertido2;
        ResultadoString = String.valueOf(Resultado);
        //lDisplay.setText(ResultadoString);
        flag = false;
    }else{
        Convertido2 = Double.parseDouble(Digitos);
        Digitos = "";
        Resultado = Convertido1 * Convertido2;
        Convertido1 = 0;
        ResultadoString = String.valueOf(Resultado);
        lDisplay.setText(ResultadoString);
        Convertido2 = Resultado;
        flag = true;
    }
}                                              

private void bNro7ActionPerformed(java.awt.event.ActionEvent evt) {                                      
   Adds = "7";
    Digitos += Adds;
    lDisplay.setText(Digitos);
}                                     

private void bNro8ActionPerformed(java.awt.event.ActionEvent evt) {                                      
    Adds = "8";
    Digitos += Adds;
    lDisplay.setText(Digitos);
}                                     

private void bNro9ActionPerformed(java.awt.event.ActionEvent evt) {                                      
    Adds = "9";
    Digitos += Adds;
    lDisplay.setText(Digitos);
}                                     

private void bDivisaoActionPerformed(java.awt.event.ActionEvent evt) {                                         
    if(flag == true){
        Convertido1 = Double.parseDouble(Digitos);
        Digitos = "";
        Resultado = Convertido1 / Convertido2;
        ResultadoString = String.valueOf(Resultado);
        //lDisplay.setText(ResultadoString);
        flag = false;
    }else{
        Convertido2 = Double.parseDouble(Digitos);
        Digitos = "";
        Resultado = Convertido1 / Convertido2;
        Convertido1 = 0;
        ResultadoString = String.valueOf(Resultado);
        lDisplay.setText(ResultadoString);
        Convertido2 = Resultado;
        flag = true;
    }
}                                        

private void bVirgulaActionPerformed(java.awt.event.ActionEvent evt) {                                         
    Adds = ",";
    Digitos += Adds;
    lDisplay.setText(Digitos);
}                                        

private void bNro0ActionPerformed(java.awt.event.ActionEvent evt) {                                      
    Adds = "0";
    Digitos += Adds;
    lDisplay.setText(Digitos);
}                                     

private void bSomaActionPerformed(java.awt.event.ActionEvent evt) {                                      
    if(flag == true){
        Convertido1 = Double.parseDouble(Digitos);
        Digitos = "";
        Resultado = Convertido1 + Convertido2;
        ResultadoString = String.valueOf(Resultado);
        lDisplay.setText(ResultadoString);
        flag = false;
    }else{
        Convertido2 = Double.parseDouble(Digitos);
        Digitos = "";
        Resultado = Convertido1 + Convertido2;
        Convertido1 = 0;
        ResultadoString = String.valueOf(Resultado);
        lDisplay.setText(ResultadoString);
        Convertido2 = Resultado;
        flag = true;
    }

}                                     

private void bIgualActionPerformed(java.awt.event.ActionEvent evt) {                                       
    // TODO add your handling code here:
}                                      

private void bCActionPerformed(java.awt.event.ActionEvent evt) {                                   
    lDisplay.setText("");
    Adds = "";
    Digitos ="";
    flag = true;
    Convertido1 = 0;
    Convertido2 = 0;
}                                  

public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new InterfaceCalc().setVisible(true);
        }
    });
}

// Variables declaration - do not modify                     
private javax.swing.JButton bC;
private javax.swing.JButton bDivisao;
private javax.swing.JButton bIgual;
private javax.swing.JButton bMultiplicacao;
private javax.swing.JButton bNro0;
private javax.swing.JButton bNro1;
private javax.swing.JButton bNro2;
private javax.swing.JButton bNro3;
private javax.swing.JButton bNro4;
private javax.swing.JButton bNro5;
private javax.swing.JButton bNro6;
private javax.swing.JButton bNro7;
private javax.swing.JButton bNro8;
private javax.swing.JButton bNro9;
private javax.swing.JButton bSoma;
private javax.swing.JButton bSubtracao;
private javax.swing.JButton bVirgula;
private javax.swing.JToggleButton jToggleButton1;
private javax.swing.JLabel lDisplay;
// End of variables declaration                   

}[/code]

entaum brother tenhu uma que é feito em java mas é feito no eclipse

dá uma olhada pode servir algo falou!!!

:arrow: :arrow:

[code]import javax.swing.;
import java.awt.
;
import java.awt.event.*;

public class Calculadora extends JFrame implements ActionListener {

	private static final long serialVersionUID = 1L;
private JButton somar, subtrair, multiplicar, dividir, limpar, voltar, igual, ponto;
private JButton bt0, bt1, bt2, bt3, bt4, bt5, bt6, bt7, bt8, bt9;
private JTextField tfVisor;
private double n1, n2;
private char operacao = ' ';
private boolean segundo = true;
private boolean utd = false;

public Calculadora() {
    //Ajuste do formulário
    setTitle("Calculadora");
    setSize(245, 260);
    setLocation(WIDTH, WIDTH);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setResizable(false);
    getContentPane().setLayout(null);

    //Inicialização dos botões
    somar = new JButton("+");
    subtrair = new JButton("-");
    multiplicar = new JButton("*");
    dividir = new JButton("/");
    limpar = new JButton("CE");
    voltar = new JButton("Backspace");
    igual = new JButton("=");
    ponto = new JButton(",");
    bt0 = new JButton("0");
    bt1 = new JButton("1");
    bt2 = new JButton("2");
    bt3 = new JButton("3");
    bt4 = new JButton("4");
    bt5 = new JButton("5");
    bt6 = new JButton("6");
    bt7 = new JButton("7");
    bt8 = new JButton("8");
    bt9 = new JButton("9");
    tfVisor = new JTextField();

    //Posicionar componentes no formulário
    tfVisor.setBounds(10, 10, 220, 40);

    voltar.setBounds(10, 55, 160, 30);
    limpar.setBounds(180, 55, 50, 30);

    bt7.setBounds(10, 90, 50, 30);
    bt8.setBounds(65, 90, 50, 30);
    bt9.setBounds(120, 90, 50, 30);
    dividir.setBounds(180, 90, 50, 30);

    bt4.setBounds(10, 125, 50, 30);
    bt5.setBounds(65, 125, 50, 30);
    bt6.setBounds(120, 125, 50, 30);
    multiplicar.setBounds(180, 125, 50, 30);

    bt1.setBounds(10, 160, 50, 30);
    bt2.setBounds(65, 160, 50, 30);
    bt3.setBounds(120, 160, 50, 30);
    subtrair.setBounds(180, 160, 50, 30);

    bt0.setBounds(10, 195, 50, 30);
    ponto.setBounds(65, 195, 50, 30);
    igual.setBounds(120, 195, 50, 30);
    somar.setBounds(180, 195, 50, 30);

    //Cores dos componentes
    bt0.setForeground(Color.BLUE);
    bt1.setForeground(Color.BLUE);
    bt2.setForeground(Color.BLUE);
    bt3.setForeground(Color.BLUE);
    bt4.setForeground(Color.BLUE);
    bt5.setForeground(Color.BLUE);
    bt6.setForeground(Color.BLUE);
    bt7.setForeground(Color.BLUE);
    bt8.setForeground(Color.BLUE);
    bt9.setForeground(Color.BLUE);
    ponto.setForeground(Color.BLUE);

    somar.setForeground(Color.red);
    subtrair.setForeground(Color.red);
    multiplicar.setForeground(Color.red);
    dividir.setForeground(Color.red);
    igual.setForeground(Color.red);
    limpar.setForeground(Color.red);
    voltar.setForeground(Color.red);

    tfVisor.setHorizontalAlignment(JTextField.RIGHT);

    //Registro de componentes que executam ações

    bt0.addActionListener(this);
    bt1.addActionListener(this);
    bt2.addActionListener(this);
    bt3.addActionListener(this);
    bt4.addActionListener(this);
    bt5.addActionListener(this);
    bt6.addActionListener(this);
    bt7.addActionListener(this);
    bt8.addActionListener(this);
    bt9.addActionListener(this);
    somar.addActionListener(this);
    subtrair.addActionListener(this);
    multiplicar.addActionListener(this);
    dividir.addActionListener(this);
    igual.addActionListener(this);
    limpar.addActionListener(this);
    voltar.addActionListener(this);
    ponto.addActionListener(this);

    //Colocar os componentes no formulário
    this.getContentPane().add(somar);
    this.getContentPane().add(subtrair);
    this.getContentPane().add(multiplicar);
    this.getContentPane().add(dividir);
    this.getContentPane().add(tfVisor);
    this.getContentPane().add(bt0);
    this.getContentPane().add(bt1);
    this.getContentPane().add(bt2);
    this.getContentPane().add(bt3);
    this.getContentPane().add(bt4);
    this.getContentPane().add(bt5);
    this.getContentPane().add(bt6);
    this.getContentPane().add(bt7);
    this.getContentPane().add(bt8);
    this.getContentPane().add(bt9);
    this.getContentPane().add(igual);
    this.getContentPane().add(limpar);
    this.getContentPane().add(voltar);
    this.getContentPane().add(dividir);
    this.getContentPane().add(ponto);
}

public static void main(String args[]) {
    JFrame obj = new Calculadora();
    obj.setVisible(true);
}

public void actionPerformed(ActionEvent acao) {
    if (acao.getSource() == bt0) {
        if (tfVisor.getText().equals("")) {
            return;
        } else {
            numDigi("0");
        }
    } else if (acao.getSource() == bt1) {
        numDigi("1");
    } else if (acao.getSource() == bt2) {
        numDigi("2");
    } else if (acao.getSource() == bt3) {
        numDigi("3");
    } else if (acao.getSource() == bt4) {
        numDigi("4");
    } else if (acao.getSource() == bt5) {
        numDigi("5");
    } else if (acao.getSource() == bt6) {
        numDigi("6");
    } else if (acao.getSource() == bt7) {
        numDigi("7");
    } else if (acao.getSource() == bt8) {
        numDigi("8");
    } else if (acao.getSource() == bt9) {
        numDigi("9");
    } else if (acao.getSource() == ponto) {
        decimal();
    }
    if (acao.getSource() == limpar) {
        tfVisor.setText("");
        operacao = ' ';
        segundo = true;
        utd = false;
        n1 = 0;
        n2 = 0;
    }
    if (acao.getSource() == voltar) {
        int tam = tfVisor.getText().length();
        if (tam > 0) {
            tfVisor.setText(tfVisor.getText().substring(0, tam - 1));
        } else {
            return;
        }
    }
    if (acao.getSource() == somar) {
        igual();
        calcular('+');
    }
    if (acao.getSource() == subtrair) {
        igual();
        calcular('-');
    }
    if (acao.getSource() == multiplicar) {
        igual();
        calcular('*');
    }
    if (acao.getSource() == dividir) {
        igual();
        calcular('/');
    }
    if (acao.getSource() == igual) {
        igual();
    }
}

private void calcular(char c) {
    if (!tfVisor.getText().equals("")) {
        operacao = c;
        segundo = false;
        utd = false;
        n1 = Double.parseDouble(tfVisor.getText());
    } else {
        return;
    }
}

private void numDigi(String n) {
    if (segundo == true) {
        tfVisor.setText(tfVisor.getText() + n);
    } else {
        tfVisor.setText("");
        tfVisor.setText(tfVisor.getText() + n);
        segundo = true;
    }
}

private void igual() {
    if (operacao == '+') {
        n2 = n1 + Double.parseDouble(tfVisor.getText());
        tfVisor.setText("" + n2);
        n1 = 0;
        n2 = 0;
        operacao = ' ';
        segundo = false;
    } else if (operacao == '-') {
        n2 = n1 - Double.parseDouble(tfVisor.getText());
        tfVisor.setText("" + n2);
        n1 = 0;
        n2 = 0;
        operacao = ' ';
    } else if (operacao == '*') {
        n2 = n1 * Double.parseDouble(tfVisor.getText());
        tfVisor.setText("" + n2);
        n1 = 0;
        n2 = 0;
        operacao = ' ';
    } else if (operacao == '/') {
        n2 = n1 / Double.parseDouble(tfVisor.getText());
        tfVisor.setText("" + n2);
        n1 = 0;
        n2 = 0;
        operacao = ' ';
    } else {
        return;
    }
}

private void decimal() {
    if (utd == false) {
        if (tfVisor.getText().length() < 1) {
            numDigi("0.");
        }
        else if (possuePonto() == true){
                return;
            }
            else{
            numDigi(".");
            }
        }
        utd = true;
    
}

private boolean possuePonto(){
    String v = tfVisor.getText();
    boolean b = false;
    for (int i = 0; i<v.length();i++){
        if (v.substring(i, i).equals(".")){
            b = true;
        }
        else {
            b = false;
        }
    }
    return b;
}

}[/code]

Opa cara, valeu…
Desculpa demorar para responder…=D
me ajudou sim…esse teu código…valeu…
abraço