How do I programmatically send an ActionEvent
(eg button pressed/ACTION_PERFORMED) to a JButton
?
I know of:
button.doClick(
You can get a button's ActionListener
s, and then call the actionPerformed
method directly.
ActionEvent event;
long when;
when = System.currentTimeMillis();
event = new ActionEvent(button, ActionEvent.ACTION_PERFORMED, "Anything", when, 0);
for (ActionListener listener : button.getActionListeners()) {
listener.actionPerformed(event);
}