Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JButton not performing action

843807Aug 27 2009 — edited Oct 2 2009
I've been seeing a intermittently-reproducible problem with some of my buttons recently.

I have a button that I created by passing in a simple action, e.g.

...
JButton runButton = new JButton(new RunAction()); 
...

public class RunAction extends AbstractAction
	{
          System.err.println("action!");
          // do something
        }
The button is part of a simulation that is doing a lot of work and spending lots of time painting, so is probably putting a lot of weight on the event-dispatching(?) thread.

The problem is that when the simulation is running, I fairly frequently find that I can push the button, see the button change in the UI, and yet the RunAction is not called (which I can tell because it should print something to standard error).

My questions are:

1) Does it make sense that I might see the button get pressed (so something knew it was clicked), but the button's action doesn't get called?

2) How can I prevent this from happening?

Note that this appears to only happen on Windows (Vista) -- I haven't seen this on my Mac.

Thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 30 2009
Added on Aug 27 2009
14 comments
386 views