viernes, 28 de noviembre de 2014

Formulario "Carreras" (Netbeans)

Diseño

diseño del formulario en netbeans

Codigo

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author CBTIS73
 */
public class checkbox extends javax.swing.JFrame {
void carreras(){
    String mensaje=("carreras Elejidas");
    if(chkDerecho.isSelected()){
        mensaje=mensaje+"Derecho";
    }
    if (chkSistemas.isSelected()){
        mensaje=mensaje+"Sistemas";
    }
    if (chkContabilidad.isSelected()){
        mensaje=mensaje+"Contabilidad";
    }
    if (chkEconomia.isSelected()){
        mensaje=mensaje+"Economia";
    }
    lblRespuesta.setText(mensaje);
}
void limpiar(){
    lblRespuesta.setText("");
    if(chkDerecho.isSelected()){
        chkDerecho.setSelected(false);
    }
    if(chkSistemas.isSelected()){
        chkSistemas.setSelected(false);
    }
    if(chkContabilidad.isSelected()){
        chkContabilidad.setSelected(false);
    }
    if(chkEconomia.isSelected()){
        chkEconomia.setSelected(false);
    }
}
    /**
     *
     */
    public checkbox() {
        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();
        chkDerecho = new javax.swing.JCheckBox();
        chkSistemas = new javax.swing.JCheckBox();
        chkContabilidad = new javax.swing.JCheckBox();
        chkEconomia = new javax.swing.JCheckBox();
        btnAceptar = new javax.swing.JButton();
        btnNuevo = new javax.swing.JButton();
        lblRespuesta = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(204, 0, 0));
        jLabel1.setText("Eleccion de carreras");

        chkDerecho.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        chkDerecho.setText("Derecho");

        chkSistemas.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        chkSistemas.setText("Sistemas");

        chkContabilidad.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        chkContabilidad.setText("Contabilidad");

        chkEconomia.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        chkEconomia.setText("Economia");

        btnAceptar.setText("Aceptar");
        btnAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAceptarActionPerformed(evt);
            }
        });

        btnNuevo.setText("Nuevo");
        btnNuevo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNuevoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(89, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addGap(84, 84, 84))
            .addGroup(layout.createSequentialGroup()
                .addGap(72, 72, 72)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(chkEconomia)
                    .addComponent(chkContabilidad)
                    .addComponent(chkSistemas)
                    .addComponent(chkDerecho))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addComponent(btnAceptar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btnNuevo)
                .addGap(114, 114, 114))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblRespuesta, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(24, 24, 24))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(chkDerecho)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(chkSistemas)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(chkContabilidad)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(chkEconomia)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnAceptar)
                    .addComponent(btnNuevo))
                .addGap(18, 18, 18)
                .addComponent(lblRespuesta, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(66, Short.MAX_VALUE))
        );

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

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

    private void btnNuevoActionPerformed(java.awt.event.ActionEvent evt) {                                         
limpiar();        // 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(checkbox.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(checkbox.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(checkbox.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(checkbox.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 checkbox().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify                     
    javax.swing.JButton btnAceptar;
    javax.swing.JButton btnNuevo;
    javax.swing.JCheckBox chkContabilidad;
    javax.swing.JCheckBox chkDerecho;
    javax.swing.JCheckBox chkEconomia;
    javax.swing.JCheckBox chkSistemas;
    javax.swing.JLabel jLabel1;
    javax.swing.JLabel lblRespuesta;
    // End of variables declaration                   
}

Resusltado



No hay comentarios:

Publicar un comentario