protected JTree newTree ( ) { JTree tree = new JTree ( ) ; tree . setModel ( newTreeModel ( getModel ( ) ) ) ; tree . setEditable ( true ) ; tree . getSelectionModel ( ) . setSelectionMode ( TreeSelectionModel . SINGLE_TREE_SELECTION ) ; tree . addMouseListener ( new MouseAdapter ( ) { @ Override public void mousePressed ( MouseEvent e ) { int selRow = tree . getRowForLocation ( e . getX ( ) , e . getY ( ) ) ; if ( selRow != - 1 ) { if ( e . getClickCount ( ) == 1 ) { onSingleClick ( e ) ; } else if ( e . getClickCount ( ) == 2 ) { onDoubleClick ( e ) ; } } } } ) ; return tree ; }
New tree .