0
I have several buttons and I would like to compare the text of the button clicked with a variable of type String
.
That without using it:
if (evento.getSource() == botaoXl) {
// Fazer isto...
} else if (evento.getSource() == botaoY) {
// Fazer aquilo...
}
Why do you want to check for the string? The text of the buttons will be dynamic? You can add a listen to the buttons and perform such behavior. You are using which GUI?
– rogue_psycho
setActionCommand
andgetActionCommand
are there for that.– Renan Gomes
I put the tag swing on your question because that sounds like swing to me. If not, then I ask you to edit the question specifying exactly what the technology or framework you are using.
– Victor Stafusa