简体   繁体   English

如何使用Java ActionListener中的代码单击JButton

[英]How to click JButton with code in java ActionListener

So, if you had a JButton with an ActionListener coded, I understand if you ran the program and clicked the button, it will process the commands we wrote in the actionlistener. 因此,如果您有一个带有ActionListener编码的JButton,那么我了解您是否运行了程序并单击了按钮,它将处理我们在actionlistener中编写的命令。 But my question is, is there any way we can CLICK the button on command within java codes? 但是我的问题是,有什么办法可以在Java代码中单击命令上的按钮? I want my code to click the button for me 我希望我的代码为我单击按钮

根据其父级AbstractButton的API调用JButton上的doClick()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM