Lillian pointed that JTree now is displayed a little bit differently
than in Sun's jre. This patch makes the tree to look more similar.
2006-04-25 Audrius Meskauskas <[EMAIL PROTECTED]>
* javax/swing/plaf/basic/BasicTreeUI.java
(NodeDimensionsHandler.getRowX): Add half of the icon width.
(paintExpandControl): Always paint in one gap distance from the left
border of the path bounds.
(paintHorizontalPartOfLeg): Rewritted, taking the icon width
into consideration.
(paintVerticalPartOfLeg): Paint two gaps from the parent's bounds
left edge.
Index: BasicTreeUI.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/plaf/basic/BasicTreeUI.java,v
retrieving revision 1.129
diff -u -r1.129 BasicTreeUI.java
--- BasicTreeUI.java 25 Apr 2006 15:23:02 -0000 1.129
+++ BasicTreeUI.java 25 Apr 2006 16:53:04 -0000
@@ -2444,7 +2444,8 @@
*/
protected int getRowX(int row, int depth)
{
- return depth * rightChildIndent;
+ int iw = getCurrentControlIcon(null).getIconWidth();
+ return depth * (rightChildIndent + iw/2);
}
}// NodeDimensionsHandler
@@ -3209,9 +3210,7 @@
{
Icon icon = getCurrentControlIcon(path);
int iconW = icon.getIconWidth();
- int x = bounds.x - rightChildIndent + iconW / 2;
- if (x + iconW > bounds.x)
- x = bounds.x - rightChildIndent - gap;
+ int x = bounds.x - iconW - gap;
icon.paintIcon(tree, g, x, bounds.y + bounds.height / 2
- icon.getIconHeight() / 2);
}
@@ -3240,8 +3239,12 @@
boolean isLeaf)
{
if (row != 0)
- paintHorizontalLine(g, tree, bounds.y + bounds.height / 2, bounds.x - gap
- - 2, bounds.x);
+ {
+ Icon icon = getCurrentControlIcon(path);
+ int iconW = icon.getIconWidth();
+ paintHorizontalLine(g, tree, bounds.y + bounds.height / 2,
+ bounds.x - iconW/2 - gap, bounds.x - gap);
+ }
}
/**
@@ -3261,7 +3264,7 @@
if (parent != null)
{
Rectangle parentBounds = getPathBounds(tree, parent);
- paintVerticalLine(g, tree, parentBounds.x + gap + 2,
+ paintVerticalLine(g, tree, parentBounds.x + 2* gap,
parentBounds.y + parentBounds.height / 2,
bounds.y + bounds.height / 2);
}