tags:

views:

32

answers:

2

SOURCE: javax.swing.JButton[,571,647,80x80,alignmentX=0.0,alignmentY=0.5,border=com.apple.laf.AquaButtonBorder$Toggle@1380cf2a,flags=288,maximumSize=java.awt.Dimension[width=80,height=80],minimumSize=java.awt.Dimension[width=80,height=80],preferredSize=java.awt.Dimension[width=80,height=80],defaultIcon=file:/Users/andreaks/Desktop/PreEntregaiDomino/build/classes/imagenes/A23.png,disabledIcon=,disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=0,left=2,bottom=0,right=2],paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=false,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=,defaultCapable=true]

NAME: null

the code im using is

private void JBsetseleccionadActionPerformed(java.awt.event.ActionEvent evt) {
    // TODO add your handling code here:
    Object boton = evt.getSource();
    JButton este= (JButton) boton;

    seleccionado = este;
    System.out.println("SOURCE " + boton.toString());
    System.out.println("NAME " + este.getName());
}

any ideas?

+1  A: 

Try something like:

String text = ((JButton) e.getSource()).getText();

BTW, a better pattern for code like this is:

private JButton button;
button = new JButton("Button");
button.addActionListener(new BListener());
private class BListener implements ActionListener{
    public void actionPerformed(ActionEvent e){
        if(e.getSource() == button){
            //code for when the JButton button is pushed
        }
    }
}
Amir Afghani
A: 

Thank you! :) it worked out

Andreaks