Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

JTree double click event

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I have a simple JTree and i wish for a new window to popup when I double click on a node in the tree. Could someone please aid me in learning how this could be done? All help is greatly appreciated.
The result would look much like say, a contact list for ICQ, where the nodes are the groups, and the leafs are the contacts. Like ICQ, i want a box to popup on doubleclick (and only a double click) for the selected Jtree leaf.
I registered a mouseListener and tree selection listener but there doesn't seem to be any type of listener for double clicks on tree elements.
Thanks
Oliver
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your mouse listener, in
mousePressed(MouseEvent e) method
do this: if (e.getSource() instanceof MyTree)
Inside this if, check for
if (e.getClickCount() == 2)
This way you can check for double-clicks in your tree.
- Raja.
 
Oliver Ng
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my apologies i'm so dumb... there is an example right in the JTree API...
thank you for the help though..
Oliver
 
You had your fun. Now it's time to go to jail. Thanks for your help tiny ad.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic