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 Enable/Disable editing of Tree Node 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 "Enable/Disable editing of Tree Node" Watch "Enable/Disable editing of Tree Node" New topic
Author

Enable/Disable editing of Tree Node

kapil Gupta
Ranch Hand

Joined: Dec 17, 2001
Posts: 89
Hi,
I have a JTree with parent nodes and leaf nodes. I want to make the parent nodes editable and leaf nodes non-editable. How can I prevent editing of leaf nodes by user
Thanks,
Kapil
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Make your tree editable, but use a custom TreeCellEditor to prevent leaf cells from being edited. I think pretty much all you'd have to do is extend DefaultTreeCellEditor, and in the getTreeCellEditorComponent() method just call setEditable( !leaf ).


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
 
subject: Enable/Disable editing of Tree Node
 
Similar Threads
JTree Leaf Node Folder
Icon change while editing tree node
nodes with no children are displayed as a leaf nodes in JTree
JTree node as non editable
Branch nodes editable