mouseClicked event

I have been having some inconsistencies with mouseEvents not firing. I have a mouseClicked event handler assigned to a radio button within a JTable. Occasionally it does not register clicks of the mouse - which obviously causes all manner of problems. I have traced the problem down and it appears to be that the mouseClicked is affected by moving the mouse between pressing and releasing - even if the mouse doesnt exit the radio button (mouseExited). I have got around this by changing to a mouseReleased but my question is:

Is this the normal behaviour or is there some sort of bug or perhaps some problem with the way they are being used.

I have researched further and this seems to happen to not just be tied to my circumstances - if you go to this address and run the MouseEventDemo you will see that if you move the mouse between clicking and releasing no mouseClicked event fires: http://java.sun.com/docs/books/tutorial/uiswing/events/mouselistener.html

Or am i being stupid?

[1009 byte] By [marsh_1sta] at [2007-11-27 2:27:46]
# 1
the order of mouseEvents is:mousePressed()mouseReleased()mouseClicked() - only if x,y coords of mousePressed == x,y of mouseReleased
Michael_Dunna at 2007-7-12 2:38:54 > top of Java-index,Java Essentials,Java Programming...
# 2
is a mouse even the best thing to capture from a radio button, anyway?
georgemca at 2007-7-12 2:38:54 > top of Java-index,Java Essentials,Java Programming...
# 3
Thanks for clarifying Michael. Would be good if the Javadocs could say something like you have just!
marsh_1sta at 2007-7-12 2:38:54 > top of Java-index,Java Essentials,Java Programming...
# 4

Hi georgemc,

With regards to whether its best to use with a radio button - probably not but that was just one example of where it is being used. The reason in that case i have needed to use a mouse event on the radio button is to be honest because i cant get a radio button correctly set up within my JTable and so i have had to create an extra column with another radio button and then emulate a radio buttongroup by having the negation of the boolean of the selected radio button set as the value of the other by my mouse listener! This mouse listener also caches changes for later saving back to db

In an ideal world i would have these two columns in a button group or possibly even better have on bit of data being represented as a pair of radio buttons

What type of listener would you suggest in the hypothetical situation that i had a working set of radio buttons within a JTable?

marsh_1sta at 2007-7-12 2:38:54 > top of Java-index,Java Essentials,Java Programming...
# 5
In the future, Swing related questions should be posted in the Swing forum.This link contains a couple of example of using radio buttons in a table which may (or may not) help: http://www.crionics.com/products/opensource/faq/swing_ex/JTableExamples2.html
camickra at 2007-7-12 2:38:54 > top of Java-index,Java Essentials,Java Programming...