• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to dynamically add and remove listeners to a button

 
celine scarlett
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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,


Any advice or help appreciated!
 
celine scarlett
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Problem all solved. Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!