Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Jpopupmenu in Jtreetable  RSS feed

 
Kevin Magee
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm trying to add a right click Jpopupmenu to a Jtreetable. I initally just tried to add a mouse listener to the component but I need the right click to select the nearest node as the functionality of the pop up menu is dependant on this.
Any one got any ideas? Help would be much appreciated.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would get the location of the click and call the getPathForLocation(x, y) method of JTree to get the TreePath to the node clicked on. You would call getLastPathComponent() on the TreePath to get a reference to the actual node. To actually select the node in the tree call setSelectioPath(TreePath) with the TreePath.
 
Kevin Magee
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I tried that and it works!!! Thanks for the help! All these data models and various components have been getting a bit confusing!!! but I think I've got it now.

Thanks,
Kevin
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!