Calculadora (Reporte de Practica)
Calculadora (Reporte de Practica)
136
Reporte de Práctica
Fecha
18/06/2024
Docente
M. en T.E. Ivonne Alonso Jiménez
Centro de Bachillerato Tecnológico industrial y de servicios No. 136
Reporte de Práctica
Codigo:
public class Calculador {
/**
*
* @author Usuario
*/
public class Calculadora extends javax.swing.JFrame {
/**
* Creates new form Calculadora
*/
public double numero1,numero2,total;
public String operacion;
public Calculadora() {
initComponents();
}
/**
Centro de Bachillerato Tecnológico industrial y de servicios No. 136
Reporte de Práctica
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
Button7.setText("7");
Button7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Button7ActionPerformed(evt);
}
});
Button8.setText("8");
Button8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Button8ActionPerformed(evt);
}
});
Button9.setText("9");
Button9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Button9ActionPerformed(evt);
}
});
Button4.setText("4");
Button4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Button4ActionPerformed(evt);
}
});
Button5.setText("5");
Button5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Button5ActionPerformed(evt);
}
});
Button6.setText("6");
Button6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Button6ActionPerformed(evt);
}
});
Button1.setText("1");
Button1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Button1ActionPerformed(evt);
}
});
Button2.setText("2");
Centro de Bachillerato Tecnológico industrial y de servicios No. 136
Reporte de Práctica
Button2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Button2ActionPerformed(evt);
}
});
Button3.setText("3");
Button3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Button3ActionPerformed(evt);
}
});
Button0.setText("0");
Button0.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Button0ActionPerformed(evt);
}
});
Buttonpunto.setText(".");
Buttonpunto.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ButtonpuntoActionPerformed(evt);
}
});
tfPantalla.setEditable(false);
tfPantalla.setBackground(new java.awt.Color(255, 255, 255));
tfPantalla.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tfPantallaActionPerformed(evt);
}
});
Centro de Bachillerato Tecnológico industrial y de servicios No. 136
Reporte de Práctica
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(17, 17, 17)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING, false)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(Button7, javax.swing.GroupLayout.PREFERRED_SIZE, 45,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Button8, javax.swing.GroupLayout.PREFERRED_SIZE, 45,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Button9, javax.swing.GroupLayout.PREFERRED_SIZE, 45,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Button_Resta,
javax.swing.GroupLayout.PREFERRED_SIZE, 45,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(Button_Borrar,
javax.swing.GroupLayout.PREFERRED_SIZE, 96,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Button_Div, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Button_Multi, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING, false)
Centro de Bachillerato Tecnológico industrial y de servicios No. 136
Reporte de Práctica
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(Button4, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Button5, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Button6, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(Button1, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Button2, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(Button3, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Button_Suma,
javax.swing.GroupLayout.PREFERRED_SIZE, 45,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(Button0, javax.swing.GroupLayout.PREFERRED_SIZE, 45,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Buttonpunto, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Button_Igual, javax.swing.GroupLayout.PREFERRED_SIZE,
96, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(tfPantalla))
.addContainerGap(36, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
Centro de Bachillerato Tecnológico industrial y de servicios No. 136
Reporte de Práctica
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(tfPantalla, javax.swing.GroupLayout.PREFERRED_SIZE, 32,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BAS
ELINE)
.addComponent(Button_Borrar, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Button_Div, javax.swing.GroupLayout.PREFERRED_SIZE, 45,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Button_Multi, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BAS
ELINE)
.addComponent(Button7, javax.swing.GroupLayout.PREFERRED_SIZE, 45,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Button8, javax.swing.GroupLayout.PREFERRED_SIZE, 45,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Button9, javax.swing.GroupLayout.PREFERRED_SIZE, 45,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Button_Resta, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING, false)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BAS
ELINE)
.addComponent(Button4, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Button5, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Button6, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
Centro de Bachillerato Tecnológico industrial y de servicios No. 136
Reporte de Práctica
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BAS
ELINE)
.addComponent(Button1, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Button2, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Button3, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(Button_Suma, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BAS
ELINE)
.addComponent(Button0, javax.swing.GroupLayout.PREFERRED_SIZE, 45,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Buttonpunto, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Button_Igual, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(29, Short.MAX_VALUE))
);
pack();
setLocationRelativeTo(null);
}// </editor-fold>
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional)
">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
Centro de Bachillerato Tecnológico industrial y de servicios No. 136
Reporte de Práctica
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Calculadora.class.getName()).log(java.util.logging.Lev
el.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Calculadora.class.getName()).log(java.util.logging.Lev
el.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Calculadora.class.getName()).log(java.util.logging.Lev
el.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Calculadora.class.getName()).log(java.util.logging.Lev
el.SEVERE, null, ex);
}
//</editor-fold>
Captura de Ejecución:
Centro de Bachillerato Tecnológico industrial y de servicios No. 136
Reporte de Práctica