How do I programmatically send ActionEvent to JButton?

前端 未结 5 1969
太阳男子
太阳男子 2020-12-20 11:56

How do I programmatically send an ActionEvent (eg button pressed/ACTION_PERFORMED) to a JButton?

I know of:

button.doClick(         


        
5条回答
  •  情话喂你
    2020-12-20 12:20

    If you don't want to call doClick() on the button, then you can simply call the code called by the button's action. Perhaps you want to have whatever class that holds the actionPerformed method call a public method that other classes can call, and simply call this method.

提交回复
热议问题