How to identify the button that was clicked? [closed]

0

I have several buttons and I would like to compare the text of the button clicked with a variable of type String .

This without using this:

if (evento.getSource() == botaoXl) {
    // Fazer isto...
} else if (evento.getSource() == botaoY) {
    // Fazer aquilo...
}
    
asked by anonymous 30.07.2016 / 12:12

1 answer

1

How about using ((JButton) evento.getSource()).getText() ?

    
30.07.2016 / 21:27