Anda di halaman 1dari 4

ISTP: Manuel Seoane Corrales Java Swing  

CALCULADORA CON JAVA EN NETBEANS      int menosClic; 
      int divClic; 
      int multiClic; 
      int decimalClic; 
   
  private void btnLimpiarActionPerformed(java.awt.event.ActionEvent evt) 
  {                                            
          // TODO add your handling code here: 
          txtDisplay.setText(""); 
          decimalClic=0; 
      }                                           
   
      private void btnUnoActionPerformed(java.awt.event.ActionEvent evt) {                               
          // TODO add your handling code here: 
          txtDisplay.setText(txtDisplay.getText()+btnUno.getText()); 
  }                                       
   
      private void btnDosActionPerformed(java.awt.event.ActionEvent evt) {                               
         txtDisplay.setText(txtDisplay.getText()+btnDos.getText()); 
      }                                       
   
      private void btnTresActionPerformed(java.awt.event.ActionEvent evt) {                               
          // TODO add your handling code here: 
public class Calculadora extends javax.swing.JFrame {          txtDisplay.setText(txtDisplay.getText()+btnTres.getText()); 
//variables      }                                        
    double masmenos;   
    double primerdouble;      private void btnCuatroActionPerformed(java.awt.event.ActionEvent 
    double segundouble;  evt) {                                           
    double totaldouble;          // TODO add your handling code here: 
    //para los botones          txtDisplay.setText(txtDisplay.getText()+btnCuatro.getText()); 
    int masClic;      }                                          

Lic. Bernardo C. Hermitaño Atencio 
ISTP: Manuel Seoane Corrales Java Swing  
 

          // TODO add your handling code here: 
    private void btnCincoActionPerformed(java.awt.event.ActionEvent evt)          txtDisplay.setText(txtDisplay.getText()+btnCero.getText()); 
{                                               }                                        
        // TODO add your handling code here:   
        txtDisplay.setText(txtDisplay.getText()+btnCinco.getText());      private void btnPuntoActionPerformed(java.awt.event.ActionEvent evt) 
    }                                          {                                          
          // TODO add your handling code here: 
    private void btnSeisActionPerformed(java.awt.event.ActionEvent evt) {                                         
        if(decimalClic==0){ 
        // TODO add your handling code here:          txtDisplay.setText(txtDisplay.getText()+btnPunto.getText()); 
        txtDisplay.setText(txtDisplay.getText()+btnSeis.getText());          decimalClic=1; 
    }                                                 } 
      }                                         
    private void btnSieteActionPerformed(java.awt.event.ActionEvent evt) {                                          
 
        // TODO add your handling code here:      private void 
        txtDisplay.setText(txtDisplay.getText()+btnSiete.getText());  btnMasMenosActionPerformed(java.awt.event.ActionEvent evt) {                                             
          // TODO add your handling code here: 
    }                                                  
  masmenos=(Double.parseDouble(String.valueOf(txtDisplay.getText()))); 
    private void btnOchoActionPerformed(java.awt.event.ActionEvent evt)          masmenos=masmenos*(‐1); 
{                                                  txtDisplay.setText(String.valueOf(masmenos)); 
        // TODO add your handling code here:      }                                            
        txtDisplay.setText(txtDisplay.getText()+btnOcho.getText());   
    }                                             private void btnMasActionPerformed(java.awt.event.ActionEvent evt) {                               
          // TODO add your handling code here: 
    private void btnNueveActionPerformed(java.awt.event.ActionEvent          
evt) {                                           primerdouble=(Double.parseDouble(String.valueOf(txtDisplay.getText()))); 
        // TODO add your handling code here:          txtDisplay.setText(""); 
        txtDisplay.setText(txtDisplay.getText()+btnNueve.getText());          masClic=1; 
    }                                                  decimalClic=0; 
      }                                       
    private void btnCeroActionPerformed(java.awt.event.ActionEvent evt) {                                         
 

Lic. Bernardo C. Hermitaño Atencio 
ISTP: Manuel Seoane Corrales Java Swing  
 

    private void btnMenosActionPerformed(java.awt.event.ActionEvent          // TODO add your handling code here: 
evt) {                                                   
        // TODO add your handling code here:  segundouble=(Double.parseDouble(String.valueOf(txtDisplay.getText()))); 
                 if(masClic>0){ 
primerdouble=(Double.parseDouble(String.valueOf(txtDisplay.getText())));              totaldouble=primerdouble+segundouble; 
        txtDisplay.setText("");              txtDisplay.setText(String.valueOf(totaldouble)); 
        menosClic=1;              primerdouble=0; 
        decimalClic=0;              segundouble=0; 
    }                                                      masClic=0; 
          } 
    private void btnMultiplicaActionPerformed(java.awt.event.ActionEvent          if(menosClic>0){ 
evt) {                                                            totaldouble=primerdouble‐segundouble; 
        // TODO add your handling code here:              txtDisplay.setText(String.valueOf(totaldouble)); 
                     primerdouble=0; 
primerdouble=(Double.parseDouble(String.valueOf(txtDisplay.getText())));              segundouble=0; 
        txtDisplay.setText("");              menosClic=0; 
        multiClic=1;          } 
        decimalClic=0;          if(multiClic>0){ 
    }                                                           totaldouble=primerdouble*segundouble; 
              txtDisplay.setText(String.valueOf(totaldouble)); 
    private void btnDivideActionPerformed(java.awt.event.ActionEvent evt)              primerdouble=0; 
{                                                        segundouble=0; 
        // TODO add your handling code here:              multiClic=0; 
                 } 
primerdouble=(Double.parseDouble(String.valueOf(txtDisplay.getText())));          if(divClic>0){ 
        txtDisplay.setText("");              totaldouble=primerdouble/segundouble; 
     divClic=1;              txtDisplay.setText(String.valueOf(totaldouble)); 
     decimalClic=0;              primerdouble=0; 
    }                                                       segundouble=0; 
              divClic=0; 
        }    }                
    private void btnIgualActionPerformed(java.awt.event.ActionEvent evt) {                                          

Lic. Bernardo C. Hermitaño Atencio 
ISTP: Manuel Seoane Corrales Java Swing  
 

Lic. Bernardo C. Hermitaño Atencio 

Anda mungkin juga menyukai