summaryrefslogtreecommitdiff
path: root/javax/swing/tree/DefaultTreeCellRenderer.java
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2006-05-01 21:45:41 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2006-05-01 21:45:41 +0000
commit480ccb4bfcc622c1ce320c20ce992188187f7573 (patch)
treeaebfd0e230d0370ec1ac1a9b1a99b478abdc6854 /javax/swing/tree/DefaultTreeCellRenderer.java
parent4d80ae24073737202d4c51bf9efd2466fea8696d (diff)
downloadclasspath-480ccb4bfcc622c1ce320c20ce992188187f7573.tar.gz
2006-05-01 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Merge HEAD-->generics-branch for the period 2006-04-13 to 2006-05-01.
Diffstat (limited to 'javax/swing/tree/DefaultTreeCellRenderer.java')
-rw-r--r--javax/swing/tree/DefaultTreeCellRenderer.java29
1 files changed, 19 insertions, 10 deletions
diff --git a/javax/swing/tree/DefaultTreeCellRenderer.java b/javax/swing/tree/DefaultTreeCellRenderer.java
index df70ba7fb..5e93145ae 100644
--- a/javax/swing/tree/DefaultTreeCellRenderer.java
+++ b/javax/swing/tree/DefaultTreeCellRenderer.java
@@ -407,7 +407,7 @@ public class DefaultTreeCellRenderer
this.hasFocus = hasFocus;
setHorizontalAlignment(LEFT);
setOpaque(false);
- setVerticalAlignment(TOP);
+ setVerticalAlignment(CENTER);
setEnabled(true);
super.setFont(UIManager.getFont("Tree.font"));
@@ -445,8 +445,7 @@ public class DefaultTreeCellRenderer
/**
* Paints the value. The background is filled based on selected.
*
- * @param g
- * the graphics device.
+ * @param g the graphics device.
*/
public void paint(Graphics g)
{
@@ -468,17 +467,27 @@ public class DefaultTreeCellRenderer
getHorizontalTextPosition(), vr, ir, tr,
getIconTextGap());
+ // Reusing one rectangle.
+ Rectangle bounds = getBounds(ir);
+
+ bounds.x = tr.x - insets.left;
+ bounds.width = tr.width + insets.left+insets.right;
+
g.setColor(super.getBackground());
- g.fillRect(tr.x, tr.y, tr.width, tr.height - insets.top - insets.bottom);
+ g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
- // paint border
- Color b = getBorderSelectionColor();
- if (b != null)
+ super.paint(g);
+
+ // Paint the border of the focused element only (lead selection)
+ if (hasFocus)
{
- g.setColor(b);
- g.drawRect(tr.x, tr.y, tr.width, tr.height - insets.top - insets.bottom);
+ Color b = getBorderSelectionColor();
+ if (b != null)
+ {
+ g.setColor(b);
+ g.drawRect(bounds.x, bounds.y, bounds.width, bounds.height - 1);
+ }
}
- super.paint(g);
}
/**