This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Applets and the fly likes Buttons don't always react Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Buttons don Watch "Buttons don New topic

Buttons don't always react

Tristan Van Poucke
Ranch Hand

Joined: Jun 30, 2008
Posts: 47
The button's on my applet work in a very strange way.
Sometimes they react when you click them the first time and othertimes you have to click them a couple of times before they react.
I am using standard JButtons.
This is an example on how I call the method that has to be called when the button is clicked

Is this a frequent problem with applets or is something wrong with my code?
Joe Ess

Joined: Oct 29, 2001
Posts: 8874

Why aren't you using an ActionListener instead of a MouseListener? ActionListeners are the usual way to listen for button presses.
Have a look at the Button Examples in the Swing Tutorial.

"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Consider Paul's rocket mass heater.
subject: Buttons don't always react