users
[Top] [All Lists]

JTree Question (more headaches)

To: <users@xxxxxxxxxx>
Subject: JTree Question (more headaches)
From: "Brian Engel" <BEngel@xxxxxxxxxxxxx>
Date: Fri, 27 Jun 2003 16:12:36 -0400
Delivered-to: mailing list users@cinjug.org
Mailing-list: contact users-help@cinjug.org; run by ezmlm
Just when I think I understand JTree.... :-)


Say you create a JTree with the property JTree.setEditable() set to true,  
using DefaultMutableTreeNodes with a custom "userObject" i.e. using the 
constructor like DefaultMutableTreeNode(myObject). 

Whenever you edit the node in the tree (i.e. you click and pause on the text) 
JTree (or something) is replacing your userObject (myObject), with a new String 
object. 

I understand why it is doing this, it constructs the text visible in the nodes 
by calling the toString method of myObject but I don't tell it how to update 
the text in my class; that is, it is a "one-way street". I want to know 
how/where I can change this behavior such that when I user edits the text in 
the node(Textfield) I can update myObject without it defaulting to a String 
class.

I can't seem to find where this process takes place in JTree, maybe in 
DefaultTreeCellEditor? This gives the Component back for editing (Textfield) 
but I can't seem to find when the user finishes editing the text, where the 
myObject gets overwritten with a new String in the DefaultMutableTreeNode 
object. (Make sense? :-) )


So if someone can point me in the right direction I would appreciate it.....



Thanks..... (again)




<Prev in Thread] Current Thread [Next in Thread>