• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

mouse event

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
reply
    Bookmark Topic Watch Topic
  • New Topic