yourTree.addTreeSelectionListener(new javax.swing.event.
                                             TreeSelectionListener() {
            public void valueChanged(TreeSelectionEvent e) {
                processMethod(e);
            }
        });private void processMethod(TreeSelectionEvent e) {
        
        TreePath newPath = e.getNewLeadSelectionPath();
        TreePath oldPath = e.getOldLeadSelectionPath();
....}