how to dynamically add and remove listeners to a button
posted 10 years ago
I'm writing a basic swing program with two buttons and two labels. The second button's actions are linked to the state of the first button. I've managed to implement this program by using 'if' statements in both of the actionPerformed methods.
However, I'm sure there is way to dynamically achieve this adding and removing of listeners within the JButton API, but I can't find it.
Does anybody know how to achieve this within the JButton API?
Current example code for the actionPerformed methods is as follows,