Get JTree selected node
Last Updated on Tuesday, 02 April 2013 08:02
This example gives you a short overview about a single tree selection.
You need first to create your tree, define your model then add a tree selection model :
If you are using a single tree selection (TreeSelectionModel.SINGLE_TREE_SELECTION) you can get the selected path by calling the getSelectionPath(). Then you call getLastPathComponent() to have the leaf.
To configure the logging using log4J find here a sample configuration file
If you have any remark or questions feel free to put a comment.If you enjoyed this tutorial and want to promote it don't hesitate to click on
Tags: tree, model, selection, single, selected, jtree, getselectionpath(), call