• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 510
  • Last Modified:

JTree event listener on root node problem

I have a JTree to let the user build folders and items (nodes) interactively. This is done by rightclicking an existing node, a listener then opens a popup with some options... The problem is that I cannot show a popup menu when the user clicks on the ROOT node (wich seems to be default in a JTree). The listener isn't even activated when one clicks the ROOT.

I have a listener attached to the JTree:

tree.addTreeSelectionListener(new TreeSelListener());         //when node is selected
tree.addMouseListener(new PopupMenuListener());              //when tree is clicked

Following class is always triggered when a node is clicked, except for the ROOT node :

private class TreeSelListener implements TreeSelectionListener

Any ideas on this one?
0
Droezel
Asked:
Droezel
  • 2
2 Solutions
 
objectsCommented:
What exactly isn't firing
If the selection doesn't changed the the selection listener won't fire.
And right clicking doesn't actually select a node from memory, you would need to select the appropriate node in your mouse listener when the node is right clicked.
0
 
objectsCommented:
0
 
DroezelAuthor Commented:
Thanks, the problem is solved. My question wasn't clear enough, but your answers assisted in solving it...
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now