Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2007

Tip: Looking for answers? Try searching our database.

SIngle-click on JButton registers multiple times - why?

Thread view: 
Todd - 23 Aug 2007 05:24 GMT
Hello all,

I am using NetBeans 5.5.1 (can't upgrade to 6) to develop a GUI.  I
have done this many times before, but have never run across this
issue.  I don't know if it is NetBeans related, but I included which
IDE I am using in case someone believes that it may be.

So, as the subject says, when I single-click on a JButton in my GUI,
the application responds as if the button had been clicked at least
twice (sometimes more).  Is there some button setting that I am
missing?  I am utterly at a loss.

The only thing I could think of was to put a lock around the code in
the callback, however, it seems to run so quickly that the lock is
released almost as quickly as it is set, allowing the code to execute
twice.  BTW, the code is just a call to a method, whereas the method
is longer and called from multiple places.

Thanks for any insights,
Todd
Andrew Thompson - 23 Aug 2007 05:37 GMT
...
>So, as the subject says, when I single-click on a JButton in my GUI,

What GUI?*

>Thanks for any insights,

* It is probably the Java code.
Try changing the comma at column 43 of line 147
to a dot, and everything should be sweet.
Failing that fix, you might try posting an SSCCE**
of code that demonstrates this behaviour, to the
group.

** <http://www.physci.org/codes/sscce.html>

Another tip (I'm probably just about to be accused
of rudeness, for mentioning this, but..) is to always
repeat the main question in the body of a post, as
some people ignore subject/title lines.

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Todd - 23 Aug 2007 05:53 GMT
> ..
>
[quoted text clipped - 22 lines]
>
> Message posted via JavaKB.comhttp://www.javakb.com/Uwe/Forums.aspx/java-general/200708/1

Andrew,

Sorry if I posted incorrectly.  Since this is an intermitent problem,
I can not develop an SSCCE that demonstrates this behaviour.  I
understand that I forgot to mention in my original post about this
being itermitent, again apologies.

Also, since I am new to the group (and usenet groups in general) could
you explain a better way of re-iterating my question than how I did in
my second paragraph?

Thanks,
Todd
Andrew Thompson - 23 Aug 2007 06:15 GMT
...
>Sorry if I posted incorrectly.  

No need for apologies.

>..Since this is an intermitent problem,
>I can not develop an SSCCE that demonstrates this behaviour.

That is unfortunate.

>Also, since I am new to the group (and usenet groups in general) could
>you explain a better way of re-iterating my question than how I did in
>my second paragraph?

Adding 'intermitent' would have altered my initial response
significantly (as you say, it is difficult to make an SSCCE
of such problems).

My first thought was that you might have added a
MouseListener to the button by mistake, these
events will fire on 'click', but also on 'mouse over'
and 'mouse out'.  That does not explain why the
behaviour is intermitent though (unless the users
are tabbing to the button usually, but intermitently
clicking on it with the mouse!).

The only other things I can suggest based on the
available information are:
- to trawl through the bug database* looking for
anything similar.
- to post to the specialist group for GUI matters,
comp.lang.java.gui (though note that most
people who read that, flagging group, also
read c.l.j.p.).  If you intend posting to c.l.j.g.,
please mention the earlier thread here, and
add the reason for reposting.

* <http://bugs.sun.com/bugdatabase/index.jsp>

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Todd - 23 Aug 2007 07:11 GMT
Andrew,

It looks like you were on the right track thinking that I may have had
a callback improperly defined.  I had created a mouse click callback
and an action callback on the same button.  I think that there may
have been iteraction between the two, since it appears that a mouse
click is also considered an action.

What is odd is the intermittent nature of the issue.  I would think
that if a click is considered an action both callbacks would be
activated.

Todd
Roedy Green - 23 Aug 2007 11:05 GMT
>So, as the subject says, when I single-click on a JButton in my GUI,
>the application responds as if the button had been clicked at least
>twice (sometimes more).  Is there some button setting that I am
>missing?  I am utterly at a loss.

Mechanically your finger micro-vibrates and hence hits the button on
and off several times as you hit it.  Dealing with the problem is
called "debouncing".  In the olden days you did it with hardware.
Today you would do it with software to discard the fibrillations.  You
might find some adjustment in your mouse driver. Look for a "double
click" speed adjustment. You also might try a higher quality mouse.  

Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.