tree.scrollPathToVisible(tree.getLeadSelectionPath());
    public void actionPerformed(ActionEvent e)    {      int selected = tree.getLeadSelectionRow();      if (selected != -1 && isLeaf(selected))        {          TreePath anchorPath = tree.getAnchorSelectionPath();          TreePath leadPath = tree.getLeadSelectionPath();          toggleExpandState(getPathForRow(tree, selected));          // Need to do this, so that the toggling doesn't mess up the lead          // and anchor.          tree.setLeadSelectionPath(leadPath);          tree.setAnchorSelectionPath(anchorPath);        }    }