RE: JButton action listener is restarting entire program
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)
精彩评论