开发者

RE: JButton action listener is restarting entire program

开发者 https://www.devze.com 2023-02-12 06:43 出处:网络
I am writing a GUI, and I have made custom buttons using null layouts, however whenever I am adding a action listener each time the button is pressed it is reloading the entire imag开发者_JAVA百科e, m

I am writing a GUI, and I have made custom buttons using null layouts, however whenever I am adding a action listener each time the button is pressed it is reloading the entire imag开发者_JAVA百科e, making it look different, is it possible to use an action listener several times without necessarily doing a new one?


You don't need to add a new ActionListener every time you want to handle an action. Just add one and it will keep working, everytime the button is pressed the actionPerformed method is called.. and I actually don't get why you add another one everytime (they will coexist so the actionPerformed is invoked many times)

0

精彩评论

暂无评论...
验证码 换一张
取 消