Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

responing to clicks on the white portion of A JTree  RSS feed

 
Anthony Yulo
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! i want to capture mouseclicks on the portions of a JTree's white portion (the portion that are not occupied by nodes)....
I have tried using the JTree().addMouseListener method but it also captures nodeclicks.. I want to have a listener that only captures clicks on the white portion.. since another listener is responsible for node clicks/node selection...
I'm trying to get the dimensions of nodes so I can check whether the portion I clicked was a node or the white portion.. But i can't find any function to help me accomplish that...
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you add a mouselistener to the JTree, it will listen for mouse events in the 'white area' and over all the nodes. You'll have to see if any nodes are clicked on by using the getPathForLocation( x, y ) method if JTree... I think this returns null if no nodes were clicked on.
 
Anthony Yulo
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ei tnx nathan...
I got it already.. tnx for the suggestion...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!