Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a double-clicked TreeTableNode?

I'm working with Eclipse and I've got a question about JXTreeTables. I want a window, showing some information about the node, to pop up, when a node is double-clicked. Now, is it possible to get the double-clicked node of the JXTreeTable or null if the click wasn't directly on a node?

like image 228
user107043 Avatar asked Jan 30 '12 02:01

user107043


1 Answers

I've received an answer on the thread kleopatra mentioned which works perfectly fine and is simplier. Here is the code:

treeTable.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseClicked(final MouseEvent e) {
        if (e.getClickCount() != 2) {
            return;
        }

        final int rowIndex = treeTable.rowAtPoint(e.getPoint());

        if (rowIndex < 0) {
            return;
        }

        final TreeTableNode selectedNode = (TreeTableNode)treeTable.getPathForRow(rowIndex).getLastPathComponent();
    }
});
like image 136
user107043 Avatar answered Oct 16 '22 03:10

user107043