Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 410
  • Last Modified:

expalin DefaultMutableTreeNode.getUserObject()

hello there,

Could you anyone tell me what this method does precisely.and when to use it.

DefaultMutableTreeNode.getUserObject()

cheers
zolf
0
zolf
Asked:
zolf
  • 3
  • 2
1 Solution
 
objectsCommented:
it returns the object that is associated with the tree node.
you use it whenever you need to access that object
0
 
zolfAuthor Commented:

Object obj = tree.getLastSelectedPathComponent();
DefaultMutableTreeNode select = (DefaultMutableTreeNode)obj;
System.out.println(select);

Object uObject = select.getUserObject();
System.out.println(uObject);

both the statements print the same.so what is the difference
0
 
objectsCommented:
you may want to access some property of the user object
0
 
zolfAuthor Commented:

for example ??
0
 
objectsCommented:
Say each node in the tree represent a Person and you want to find out the persons name

DefaultMutableTreeNode select = (DefaultMutableTreeNode)obj;
Person p = (Person) select.getUserObject();
String name = p.getName();
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now