ActionEvent
provides a reference to the source
that triggered the event, in you case this would the JButton
.
You could simply check which button triggered the event by comparing the source with a known reference, but it would be simpler to utilise the buttons actionCommand
properties...
if ("name of action".equals(source.getActionCommand())) {...
This assumes that you set the buttons actionCommand
property.
Failing that, your down to the text...
JButton btn = (JButton)e.getSource();
if ("0".equals(btn.getText()) {...
Personally, that's just asking for trouble, as you might have multiple buttons with the same name. Better to use the buttons actionCommand
property.
A better solution would be to just use the actions API, which is self contained concept of an action which carries with it configuration information, then you don't care...