domingo, 29 de mayo de 2011

SELECCIONAR UN COLOR Y MOSTRARA EL COLOR ELEGIDO

public class NewJFrame extends javax.swing.JFrame {

    /** Creates new form NewJFrame */
    public NewJFrame() {
        initComponents();
        optrojo.setSelected(true);
    }
   private void optverdeActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
    }                                       

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

    }                                      

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
        String mensaje="  Color elegido: ";

        if (optrojo.isSelected()) {
            mensaje=mensaje+"Rojo";
        } else if (optverde.isSelected()) {
            mensaje=mensaje+"Verde";
        } else if (optazul.isSelected()) {
            mensaje=mensaje+"Azul";
        }

        this.jLabel1.setText(mensaje);

    }                                       

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new NewJFrame().setVisible(true);
            }
        });
    }

No hay comentarios:

Publicar un comentario