Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

removeActionListener if anonymous ActionListener  RSS feed

 
Pres Brawner
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's say you created an ActionListener tied to a button like this:
okButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
okButton_actionPerformed(e);
}
});
Now you want to call the removeActionListener on this button. However, removeActionListener requires an ActionListener as an argument. You did name your actionListener - it was anonymous.
You could always go back and name all of your actionListeners, then use those as the arguements in the removeActionListener statements.
Isn't there a way to do this if they're anonymous?
Thanks all,
Pres
 
eric moon
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but what if you want to remove the listener from a JComponent, say, for instance, BasicTableUI ??? How do you get a handle on it???
Sorry I don't have the answer on that one!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!