viernes, 24 de agosto de 2012


1. TALLER PROGRAMACIÓN : 
PROGRAMA DE OPERACIONES BÁSICAS


1. Código Fuente ( NetBeans)

package paqfunbas;

/**
 *
 * @author FAMILIA ARIZA
 */
public class jfunbas extends javax.swing.JFrame {

    /**
     * Creates new form jfunbas
     */
    public jfunbas() {
        initComponents();
        
    }

    /**
     * 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() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jbtnsum = new javax.swing.JButton();
        jbtnres = new javax.swing.JButton();
        jbtnmult = new javax.swing.JButton();
        jbtndiv = new javax.swing.JButton();
        jlblresultadosum = new javax.swing.JLabel();
        jtxtfunbas2 = new javax.swing.JTextField();
        jtxtfunbas1 = new javax.swing.JTextField();
        jlblresultadorest = new javax.swing.JLabel();
        jlblresultadomult = new javax.swing.JLabel();
        jlblresultadodiv = new javax.swing.JLabel();
        jlbltitulo = new javax.swing.JLabel();

        jLabel1.setText("jLabel1");

        jLabel2.setText("jLabel2");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jbtnsum.setText("SUMAR");
        jbtnsum.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnsumActionPerformed(evt);
            }
        });

        jbtnres.setText("RESTAR");
        jbtnres.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnresActionPerformed(evt);
            }
        });

        jbtnmult.setText("MULTIPLICAR");
        jbtnmult.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnmultActionPerformed(evt);
            }
        });

        jbtndiv.setText("DIVIDIR");
        jbtndiv.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtndivActionPerformed(evt);
            }
        });

        jlblresultadosum.setText("Resultado Suma");

        jtxtfunbas1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxtfunbas1ActionPerformed(evt);
            }
        });

        jlblresultadorest.setText("Resultado Resta");

        jlblresultadomult.setText("Resultado Multiplicación");

        jlblresultadodiv.setText("Resultado Division");

        jlbltitulo.setText("CALCULADORA DE OPERACIONES BASICAS");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jtxtfunbas2, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtxtfunbas1, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(23, 23, 23)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jbtnmult)
                    .addComponent(jbtndiv, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jbtnres, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jbtnsum, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(44, 44, 44)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jlblresultadosum, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jlblresultadomult)
                            .addComponent(jlblresultadorest, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jlblresultadodiv, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(171, Short.MAX_VALUE)
                .addComponent(jlbltitulo, javax.swing.GroupLayout.PREFERRED_SIZE, 383, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(129, 129, 129))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jlbltitulo, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jbtnmult)
                            .addComponent(jlblresultadomult, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(35, 35, 35))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jbtnsum)
                            .addComponent(jlblresultadosum, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(37, 37, 37)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jtxtfunbas2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jbtnres)
                            .addComponent(jlblresultadorest, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addComponent(jtxtfunbas1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(55, 55, 55)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbtndiv)
                    .addComponent(jlblresultadodiv, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(44, 44, 44))
        );

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

    private void jbtnsumActionPerformed(java.awt.event.ActionEvent evt) {                                        
Integer num1,num2;
num1=Integer.parseInt(jtxtfunbas1.getText());
num2=Integer.parseInt(jtxtfunbas2.getText());
Integer resultado;
resultado=num1 + num2;
jlblresultadosum.setText(resultado.toString());        // TODO add your handling code here:
    }                                       

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

    private void jbtnresActionPerformed(java.awt.event.ActionEvent evt) {                                        
Integer num1,num2;
num1=Integer.parseInt(jtxtfunbas1.getText());
num2=Integer.parseInt(jtxtfunbas2.getText());
Integer resultado;
resultado=num1 - num2;
jlblresultadorest.setText(resultado.toString());     // TODO add your handling code here:
    }                                       

    private void jbtnmultActionPerformed(java.awt.event.ActionEvent evt) {                                         
Integer num1,num2;
num1=Integer.parseInt(jtxtfunbas1.getText());
num2=Integer.parseInt(jtxtfunbas2.getText());
Integer resultado;
resultado=num1 * num2;
jlblresultadomult.setText(resultado.toString());        // TODO add your handling code here:
    }                                        

    private void jbtndivActionPerformed(java.awt.event.ActionEvent evt) {                                        
Integer num1,num2;
num1=Integer.parseInt(jtxtfunbas1.getText());
num2=Integer.parseInt(jtxtfunbas2.getText());
Integer resultado;
resultado=num1 / num2;
jlblresultadodiv.setText(resultado.toString());        // TODO add your handling code here:
    }                                       

    /**
     * @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())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(jfunbas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(jfunbas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(jfunbas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(jfunbas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new jfunbas().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JButton jbtndiv;
    private javax.swing.JButton jbtnmult;
    private javax.swing.JButton jbtnres;
    private javax.swing.JButton jbtnsum;
    private javax.swing.JLabel jlblresultadodiv;
    private javax.swing.JLabel jlblresultadomult;
    private javax.swing.JLabel jlblresultadorest;
    private javax.swing.JLabel jlblresultadosum;
    private javax.swing.JLabel jlbltitulo;
    private javax.swing.JTextField jtxtfunbas1;
    private javax.swing.JTextField jtxtfunbas2;
    // End of variables declaration
}


2. Comprimido del Programa

No hay comentarios:

Publicar un comentario