Link to home
Start Free TrialLog in
Avatar of Droezel
Droezel

asked on

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?
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Droezel
Droezel

ASKER

Thanks, the problem is solved. My question wasn't clear enough, but your answers assisted in solving it...