Reputation: 2178
I have one class where there are certain swing components.
In second class (as per requirement), I need to simulate the button click event ultimately calling the actionPerformed(ActionEvent ae)
. This button is in the first class(described in the first line).
How do I do so?
I have tried to go through the fireActionPerformed(ActionEvent ae)
. However, I am unable to come to a solution.
A small snippet (as an example) would be very much helpful.
EDIT Note: I also need to disable the button, when I click it or simulate its click.
Pardon me if this has already been asked before. Though I have searched for similar question before.
Thanks and Regards.
Upvotes: 0
Views: 3603
Reputation: 57381
JButton has doClick() method but it's better to define one doMyAction() method and call it from both places.
Upvotes: 8