Index: javax/swing/JTable.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/JTable.java,v retrieving revision 1.59 diff -u -r1.59 JTable.java --- javax/swing/JTable.java 2 Nov 2005 11:07:29 -0000 1.59 +++ javax/swing/JTable.java 7 Nov 2005 22:13:55 -0000 @@ -1768,9 +1768,14 @@ // If the structure changes, we need to revalidate, since that might // affect the size parameters of the JTable. Otherwise we only need // to perform a repaint to update the view. - if (event.getType() == TableModelEvent.INSERT - || event.getType() == TableModelEvent.DELETE) + if (event.getType() == TableModelEvent.INSERT) revalidate(); + else if (event.getType() == TableModelEvent.DELETE) + { + if (dataModel.getRowCount() == 0) + clearSelection(); + revalidate(); + } repaint(); } @@ -1890,7 +1895,7 @@ * @return The current value of the selectedRow property */ public int getSelectedRow () - { + { return selectionModel.getMinSelectionIndex(); } Index: javax/swing/JTree.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/JTree.java,v retrieving revision 1.49 diff -u -r1.49 JTree.java --- javax/swing/JTree.java 19 Oct 2005 15:45:04 -0000 1.49 +++ javax/swing/JTree.java 7 Nov 2005 22:13:55 -0000 @@ -2065,7 +2065,8 @@ } Rectangle rect = getPathBounds(path); scrollRectToVisible(rect); - setSelectionPath(temp); + revalidate(); + repaint(); } public void scrollRowToVisible(int row) @@ -2363,8 +2364,8 @@ public void expandPath(TreePath path) { - // Don't expand if last path component is a leaf node. - if ((path == null) || (treeModel.isLeaf(path.getLastPathComponent()))) + // Don't expand if path is null + if (path == null) return; try Index: javax/swing/plaf/basic/BasicTreeUI.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTreeUI.java,v retrieving revision 1.106 diff -u -r1.106 BasicTreeUI.java --- javax/swing/plaf/basic/BasicTreeUI.java 3 Nov 2005 22:06:10 -0000 1.106 +++ javax/swing/plaf/basic/BasicTreeUI.java 7 Nov 2005 22:13:55 -0000 @@ -700,6 +700,7 @@ */ public int getRowCount(JTree tree) { + updateCurrentVisiblePath(); if (currentVisiblePath != null) return currentVisiblePath.getPathCount(); return 0; @@ -1413,7 +1414,7 @@ if (currentVisiblePath == null) updateCurrentVisiblePath(); - if (treeModel != null) + if (currentVisiblePath != null && treeModel != null) { Object root = treeModel.getRoot(); paintRecursive(g, 0, 0, 0, tree, treeModel, root); @@ -2510,7 +2511,13 @@ */ public void propertyChange(PropertyChangeEvent event) { - // TODO: What should be done here, if anything? + if ((event.getPropertyName()).equals("rootVisible")) + { + validCachedPreferredSize = false; + updateCurrentVisiblePath(); + tree.revalidate(); + tree.repaint(); + } } } @@ -3170,11 +3179,14 @@ int max = mod.getChildCount(curr); for (int i = 0; i < max; i++) { + Object child = mod.getChild(curr, i); + boolean childVis = tree.isVisible(new TreePath + (getPathToRoot(child, 0))); int indent = indentation + rightChildIndent; if (!isRootVisible && depth == 0) indent = 0; else if (isRootVisible || - (!isRootVisible && !curr.equals(root))) + (!isRootVisible && !curr.equals(root)) && childVis) { g.setColor(getHashColor()); heightOfLine = descent + halfHeight; @@ -3183,20 +3195,21 @@ } descent = paintRecursive(g, indent, descent, depth + 1, - tree, mod, mod.getChild(curr, i)); + tree, mod, child); } } } if (isExpanded) - if (y0 != heightOfLine && !isLeaf - && mod.getChildCount(curr) > 0) + if (y0 != heightOfLine + && (mod.getChildCount(curr) > 0 && + tree.isVisible(new TreePath(getPathToRoot(mod.getChild + (curr, 0), 0))))) { g.setColor(getHashColor()); - paintVerticalLine(g, (JComponent) tree, indentation + halfWidth, - y0, heightOfLine); + paintVerticalLine(g, (JComponent) tree, indentation + halfWidth, y0, + heightOfLine); } - return descent; } @@ -3266,11 +3279,12 @@ for (int i = 0; i < max; i++) { int indent = indentation + rightChildIndent; + Object child = mod.getChild(node, i); if (depth == 0 && !tree.isRootVisible()) indent = 1; - - descent = paintControlIcons(g, indent, descent, depth + 1, - tree, mod, mod.getChild(node, i)); + if (tree.isVisible(new TreePath(getPathToRoot(child, 0)))) + descent = paintControlIcons(g, indent, descent, depth + 1, + tree, mod, child); } } } @@ -3359,6 +3373,7 @@ */ Object getPreviousVisibleNode(Object node) { if (currentVisiblePath != null) { Object[] nodes = currentVisiblePath.getPath(); @@ -3366,7 +3381,7 @@ while (i < nodes.length && !node.equals(nodes[i])) i++; // return the next node - if (i-1 > 0) + if (i-1 >= 0) return nodes[i-1]; } return null; @@ -3760,7 +3775,7 @@ dtcr = createDefaultCellRenderer(); Component c = dtcr.getTreeCellRendererComponent(tree, node, - selected, isExpanded, isLeaf, row, false); + selected, isExpanded, isLeaf, row, true); rendererPane.paintComponent(g, c, c.getParent(), bounds); } } @@ -3825,17 +3841,23 @@ do { TreePath path = new TreePath(getPathToRoot(next, 0)); - if (tree.isVisible(path) && tree.isExpanded(path)) + if ((tree.isVisible(path) && tree.isExpanded(path)) || + treeModel.isLeaf(next)) next = getNextNode(next); - else next = getNextSibling(next); + else + next = getNextSibling(next); } while (next != null && !tree.isVisible(new TreePath(getPathToRoot(next, 0)))); } currentVisiblePath = current; if (tree.getSelectionModel() != null && tree.getSelectionCount() == 0 && currentVisiblePath != null) - tree.addSelectionRow(0); + selectPath(tree, new TreePath(currentVisiblePath.getPathComponent(0))); } /** Index: javax/swing/tree/DefaultTreeCellRenderer.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/tree/DefaultTreeCellRenderer.java,v retrieving revision 1.21 diff -u -r1.21 DefaultTreeCellRenderer.java --- javax/swing/tree/DefaultTreeCellRenderer.java 2 Sep 2005 18:03:25 -0000 1.21 +++ javax/swing/tree/DefaultTreeCellRenderer.java 7 Nov 2005 22:13:55 -0000 @@ -419,8 +419,7 @@ super.setBackground(getBackgroundSelectionColor()); setForeground(getTextSelectionColor()); - if (tree.getLeadSelectionPath() == null || - (tree.getLeadSelectionPath().getLastPathComponent()).equals(val)) + if (hasFocus) setBorderSelectionColor(UIManager.getLookAndFeelDefaults(). getColor("Tree.selectionBorderColor")); else