Foros del Web » Programación para mayores de 30 ;) » Java »

Problemas con calculadora en Netbeans teclas(.), (CE),(salir) como las programo?

Estas en el tema de Problemas con calculadora en Netbeans teclas(.), (CE),(salir) como las programo? en el foro de Java en Foros del Web. Cordial saludo Amigos estoy realisando una calculadora con algunas funciones basicas pero nose como programar el evento del botos de (.),(CE) y (Salir). les agradeseria ...
  #1 (permalink)  
Antiguo 11/11/2012, 22:55
Avatar de afal3d  
Fecha de Ingreso: octubre-2012
Mensajes: 24
Antigüedad: 11 años, 6 meses
Puntos: 0
Pregunta Problemas con calculadora en Netbeans teclas(.), (CE),(salir) como las programo?

Cordial saludo
Amigos estoy realisando una calculadora con algunas funciones basicas pero nose como programar el evento del botos de (.),(CE) y (Salir).
les agradeseria cualquiera ayuda al respecto sobre el codigo propuesto ya que es el que he venido trabajando y me gustaria revisar y corregir el error.

Abajo de dejo el link de descarga del archivo para cualquier ayuda.


http://www.4shared.com/rar/WbJnfa5w/AppletCalculadora.html

Código:
package AppletCalculadora_GUI;

public class AppletCalculadora_GUI_SENA extends javax.swing.JApplet {
    String Numero="";
 int valor=0;
    int signo=0;
private void btn1ActionPerformed(java.awt.event.ActionEvent evt) {                                     
Numero += 1;
Numero1.setText(Numero);// TODO add your handling code here:
    }                                    

    private void btn2ActionPerformed(java.awt.event.ActionEvent evt) {                                     
Numero += 2;
Numero1.setText(Numero);  // TODO add your handling code here:
    }                                    

    private void btn3ActionPerformed(java.awt.event.ActionEvent evt) {                                     
Numero += 3;
Numero1.setText(Numero);        // TODO add your handling code here:
    }                                    

    private void btn4ActionPerformed(java.awt.event.ActionEvent evt) {                                     
Numero += 4;
Numero1.setText(Numero);        // TODO add your handling code here:
    }                                    

    private void btn5ActionPerformed(java.awt.event.ActionEvent evt) {                                     
Numero += 5;
Numero1.setText(Numero);        // TODO add your handling code here:
    }                                    

    private void btn6ActionPerformed(java.awt.event.ActionEvent evt) {                                     
Numero += 6;
Numero1.setText(Numero);        // TODO add your handling code here:
    }                                    

    private void btn7ActionPerformed(java.awt.event.ActionEvent evt) {                                     
Numero += 7;
Numero1.setText(Numero);        // TODO add your handling code here:
    }                                    

    private void btn8ActionPerformed(java.awt.event.ActionEvent evt) {                                     
Numero += 8;
Numero1.setText(Numero);        // TODO add your handling code here:
    }                                    

    private void btn9ActionPerformed(java.awt.event.ActionEvent evt) {                                     
Numero += 9;
Numero1.setText(Numero);        // TODO add your handling code here:
    }                                    

    private void btn0ActionPerformed(java.awt.event.ActionEvent evt) {                                     
Numero += 0;
Numero1.setText(Numero);        // TODO add your handling code here:
    }                                    

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

    private void btnSumaActionPerformed(java.awt.event.ActionEvent evt) {                                        
valor=Integer.parseInt(Numero);
Numero1.setText("0");
signo=1;
Numero1.setText("");
Numero="";
// TODO add your handling code here:
    }                                       

    private void btnRestaActionPerformed(java.awt.event.ActionEvent evt) {                                         
valor=Integer.parseInt(Numero);
Numero1.setText("0");
signo=2;
Numero1.setText("");
Numero="";        // TODO add your handling code here:
    }                                        

    private void btnIgualActionPerformed(java.awt.event.ActionEvent evt) {                                         
if(signo==1){
    valor += Integer.parseInt(Numero);
    Numero1.setText(Integer.toString(valor));
    }
if(signo==2){
    valor -= Integer.parseInt(Numero);
    Numero1.setText(Integer.toString(valor));
    }
if(signo==3){
    valor *= Integer.parseInt(Numero);
    Numero1.setText(Integer.toString(valor));
    }
if(signo==4){
    valor /= Integer.parseInt(Numero);
    Numero1.setText(Integer.toString(valor));
    }
Numero="";
    // TODO add your handling code here:
    }                                        

    private void btnMultiplicacionActionPerformed(java.awt.event.ActionEvent evt) {                                                  
valor=Integer.parseInt(Numero);
Numero1.setText("0");
signo=3;
Numero1.setText("");
Numero="";        // TODO add your handling code here:
    }                                                 

    private void btnDivicionActionPerformed(java.awt.event.ActionEvent evt) {                                            
valor=Integer.parseInt(Numero);
Numero1.setText("0");
signo=4;
Numero1.setText("");
Numero="";     // TODO add your handling code here:
    }                                           

    private void btnCActionPerformed(java.awt.event.ActionEvent evt) {                                     
Numero1.setText("");        // TODO add your handling code here:
    }                                    

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

    private void btnPuntoActionPerformed(java.awt.event.ActionEvent evt) {                                         
Numero=Numero.concat(".");
Numero1.setText(Numero);


// TODO add your handling code here:
    }                                        

    // Variables declaration - do not modify                     
    private javax.swing.JTextField Numero1;
    private javax.swing.JButton btn0;
    private javax.swing.JButton btn1;
    private javax.swing.JButton btn2;
    private javax.swing.JButton btn3;
    private javax.swing.JButton btn4;
    private javax.swing.JButton btn5;
    private javax.swing.JButton btn6;
    private javax.swing.JButton btn7;
    private javax.swing.JButton btn8;
    private javax.swing.JButton btn9;
    private javax.swing.JButton btnC;
    private javax.swing.JButton btnCE;
    private javax.swing.JButton btnDivicion;
    private javax.swing.JButton btnIgual;
    private javax.swing.JButton btnMultiplicacion;
    private javax.swing.JButton btnPunto;
    private javax.swing.JButton btnResta;
    private javax.swing.JButton btnSalir;
    private javax.swing.JButton btnSuma;
    // End of variables declaration                   

   
}

Me interesaria que me ayudaran a corregir la parte correspondiente a private void btnPuntoActionPerformed(java.awt.event.ActionEvent evt) y private void btnCEActionPerformed(java.awt.event.ActionEvent evt) les agradezco cualquier ayuda.

Última edición por afal3d; 15/11/2012 a las 19:37

Etiquetas: calculadora, netbeans, programa, teclas
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 03:45.