aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JtreeTable does not return complete selection path Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JtreeTable does not return complete selection path" Watch "JtreeTable does not return complete selection path" New topic
Author

JtreeTable does not return complete selection path

PraveenKumar rocks
Greenhorn

Joined: Feb 16, 2011
Posts: 1
Hi

I am new to java working on JtableTree downloaded from http://java.sun.com/products/jfc/tsc/articles/treetable2/index.html. I want to select / display the complete path (for example:"home/user/Jtree/tree.xml") when selecting a leaf node of JTreeTable. In source code of JTreeTable, in JTreeTable class they have implemented
ListSelectionListener for both table and tree. I have modified the code implemented both ListSelectionSelectionListenor and TreeSelectionListenor implemented the method for TreeSelectionevent like this:

( code snippet from JTreeTable.java class after modificaion )

class ListSelectionHandler implements ListSelectionListener, TreeSelectionListener{
public void valueChanged(ListSelectionEvent e) {
System.out.println("List selection changed listener");
//updateSelectedPathsFromSelectedRows();

}

public void valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) e
.getPath().getLastPathComponent();
if(node.isLeaf()) {
System.out.println("You selected " + node);
}
}
}

But when we select a node(non leaf/ or leaf node) TreeSelectionEvent never get control.

Is there any other way to select/ get the complete path of selected non leaf node ?

I have also tried to add mouse listener to tree and get selected path on double click of non leaf node. How we can add the mouse listener to JtableTree to get the selected node path ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JtreeTable does not return complete selection path
 
Similar Threads
How do I know which object is selected?
TreeSelectionListener interface valueChanged()
JCheckBox in Jtree Problem
JTree ------odd thing
How to find selected Nodes of JTree used TreeListener any other way.