This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes actionPerformed() called twice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "actionPerformed() called twice" Watch "actionPerformed() called twice" New topic

actionPerformed() called twice

Emili Calonge
Ranch Hand

Joined: May 17, 2003
Posts: 84
I've got a problem with a button in my program that calls the actionPerformed() twice (at least I think so) the code is this:

If I debug this code with the eclipse debugger I can see that it is entering the actionperformed function twice. I don't understand what's happening as I have other buttons with the same exact code (except the action commands) and they work perfectly. Hope anyone can help me. Thanks.
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Perhaps you're calling addActionListener again elsewhere.

There is no emoticon for what I am feeling!
Emili Calonge
Ranch Hand

Joined: May 17, 2003
Posts: 84
Yep, I hate me so much when I do this things with copy paste. Thanks.
leon liu

Joined: Jan 10, 2005
Posts: 3
In fact,Your code exactly call the actionListener twice,Maybe you can
print the message on your console,why the button had been active twice.......

My English is poor,so if my grammar is wrong.plz tell me tks..
Emili Calonge
Ranch Hand

Joined: May 17, 2003
Posts: 84
The error was that I had another button with the same action command. I don't see why you say that this code is calling actionlistener twice.
I agree. Here's the link:
subject: actionPerformed() called twice
Similar Threads
how do i generate an ActionEvent ?
GUI - Components
Which JPanel is the button on
only one window opened