This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "" Watch "" New topic
Author

Eswar Rao
Greenhorn

Joined: Oct 13, 2011
Posts: 3
Hi,

If I add the same reference of a ActionListener twice to a component then the actionPerformed method will be called twice for each action on that component ?

If yes if I remove the action listener as below will it remove both the listeners ?

myJcomboBox.addActionListener(myActionListener);
myJcomboBox.addActionListener(myActionListener);

Then remove the listener as below

myJcomboBox.removeActionListener(myActionListener);

Please clarify how this will work.
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3504
    
  14
That sounds like the sort of thing you could write a program to test.


Joanne
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3068
    
  33

Hi Eswar,
Please UseAMeaningfulSubjectLine


Mohamed Sanaulla | My Blog
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19684
    
  20

You'd better make sure any listener is only added once, to prevent having to answer this question.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38517
    
  23
Surely you’ld have to answer the question twice

And welcome to the Ranch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: