This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JTree help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTree help" Watch "JTree help" New topic

JTree help

Anand Loni
Ranch Hand

Joined: Jan 20, 2006
Posts: 150

I have Jtree and popup menu associated with tree. I have different menu items in popup menu. when i start editing tree node I want to show popup with undo,cut,copy,paste etc operation to be performed on editing tree node text.

How to do this any idea ???

~ Anand,
SCJP 1.5, SCWCD 1.5
Sam Codean
Ranch Hand

Joined: Feb 26, 2006
Posts: 194
Extend the DefaultMutableTreeNode to have a boolean array flaggin what are the options allowed for that node.
Attach the Popup Listener to this node and check the validity of these options before populating the Popup menu with the options. If valid enable else disable them. That is the simplest approach i can think of.
Hope that helps!!

-Sam Codean<br />SCJP 1.4 (98%)<br />SCJD 5.0 (87.5%)
It is sorta covered in the JavaRanch Style Guide.
subject: JTree help
Similar Threads
JPopup and JTree Problem
Displaying Data in a JTree
swing editing JTree nodes
JTree help