• Post Reply Bookmark Topic Watch Topic
  • New Topic

mouse event  RSS feed

 
Hiep Nguyen
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi room!
i don't know how to catch mouse double click event, especially for JTable, butin class MouseListener doesn't catch the event.
thank you!
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Hiep,
Double clicks are difficult to catch in Swing. You need to check for a double click in the "mouseReleased()" method (of the "MouseListener" interface). In (your implementation of) that method, you need to invoke the "getClickCount()" method (of class "MouseEvent"). Note that each click of the mouse button will fire a "mouse event", so your "mouseReleased()" method will get called twice. The first time, "getClickCount()" will return 1 (one), and the second time it will return 2 (two). However, "getClickCount()" will only return two if the mouse button was clicked twice quickly. In other words, you may click the mouse button twice, but it won't be fast enough for java to realize that it's a double click. (I told you that catching double clicks in swing is difficult :-)
Hope this helps you.
Good Luck,
Avi.
 
Hiep Nguyen
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you!
i had tryed to use that way befor post the message, and it worked as what you say, and i think it's stupid way , but now i maybe i must use it. if you have any good ideas, tell me. one more again thank you!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!