Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > [JTree] click on a node or a leaf

Reply
Thread Tools

[JTree] click on a node or a leaf

 
 
Alexandre Jaquet
Guest
Posts: n/a
 
      11-10-2003
Hi I would like to know how know if a user click on a node or a leaf
thanks.


 
Reply With Quote
 
 
 
 
Thomas Weidenfeller
Guest
Posts: n/a
 
      11-11-2003
"Alexandre Jaquet" <> writes:
> Hi I would like to know how know if a user click on a node or a leaf
> thanks.


You can ask the node if it is a leave or not. See the API documentation
of TreeNode.

/Thomas
 
Reply With Quote
 
 
 
 
Matthew Zimmer
Guest
Posts: n/a
 
      11-11-2003


Alexandre Jaquet wrote:

> Hi I would like to know how know if a user click on a node or a leaf
> thanks.
>
>


Do you mean how to know when something is selected or if the something
selected is a node or not? If you mean the first, use this:

myTree.addTreeSelectionListener(new TreeSelectionListener()
{
public void valueChanged(TreeSelectionEvent evt)
{
TreePath path = this.getSelectionPath();
if (path != null)
{
DefaultMutableTreeNode node =
(DefaultMutableTreeNode)path.getLastPathComponent( );
if (node.isLeaf())
{
// do child stuff
}
else
{
// do parent stuff
}

}
}
});


Hope that helps.
Matthew

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Leaf Node in SiteMapPath Uriah Piddle ASP .Net 3 09-17-2006 08:17 PM
xsl variable $node/text() but $node can non-node-set help! Tjerk Wolterink XML 2 08-24-2006 03:28 AM
TreeView - disabling hyperlink on the leaf node mazdotnet ASP .Net 1 08-01-2006 03:24 PM
How to set the node indent property between the parent node and the leaf node viveknatani@gmail.com ASP .Net 0 02-13-2006 07:11 PM
[JTree] Adding a leaf to a node Alexandre Jaquet Java 0 11-08-2003 06:30 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57