This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan 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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Enable/Disable editing of Tree Node
 
Similar Threads
Icon change while editing tree node
Branch nodes editable
nodes with no children are displayed as a leaf nodes in JTree
JTree Leaf Node Folder
JTree node as non editable