• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

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
 
reply
    Bookmark Topic Watch Topic
  • New Topic