Question:

JButton in java programming?

by  |  earlier

0 LIKES UnLike

how to invoke actionlistener of a JButton in java through a command

 Tags:

   Report

2 ANSWERS


  1. Just call the listener, if you know which it is.  If not, you can get the list of listeners, as a property, from the button.


  2. assume:

    JButton theButton = new JButton();

    theButton.addActionListener(yourListen...

    to programmatically invoke the listener associated with theButton (in this case yourListener), do this

    theButton.doClick();

    This will cause theButton to dispatch an ActionEvent to your listener's actionPerformed() method.

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions