aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes DefaultTreeCellRenderer not highlighting TreeNode on right-click Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "DefaultTreeCellRenderer not highlighting TreeNode on right-click" Watch "DefaultTreeCellRenderer not highlighting TreeNode on right-click" New topic
Author

DefaultTreeCellRenderer not highlighting TreeNode on right-click

Tom Katz
Ranch Hand

Joined: Aug 19, 2002
Posts: 169
I'm using a renderer that extends DefaultTreeCellRenderer. When I left-click on a tree node, it becomes highlighted. But not on a right-click. At first I thought it was because the popupMenu was stealing the focus, but I took the menu code out and same results.

So, anyone know how to highlight a tree node when it's right-clicked?
Tom Katz
Ranch Hand

Joined: Aug 19, 2002
Posts: 169
Turns out, all I needed was this code in my MouseAdapter inner class:
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: DefaultTreeCellRenderer not highlighting TreeNode on right-click