aboutsummaryrefslogtreecommitdiff
path: root/src/share/classes/javax/swing
diff options
context:
space:
mode:
authorrupashka <none@none>2008-04-28 17:17:45 +0400
committerrupashka <none@none>2008-04-28 17:17:45 +0400
commit150bb10ee9b13736eb4de3c7e3fd77208d8fa8d5 (patch)
tree7203341286925113ca4d6feeaea83f791622a212 /src/share/classes/javax/swing
parentd892b43350765e08c8eb5e7044a427459042fddb (diff)
4252173: Inability to reuse the HorizontalSliderThumbIcon
Summary: Removed casting component to JSlider from MetalIconFactory Reviewed-by: alexp
Diffstat (limited to 'src/share/classes/javax/swing')
-rw-r--r--src/share/classes/javax/swing/plaf/metal/MetalIconFactory.java34
1 files changed, 15 insertions, 19 deletions
diff --git a/src/share/classes/javax/swing/plaf/metal/MetalIconFactory.java b/src/share/classes/javax/swing/plaf/metal/MetalIconFactory.java
index 61949c7cf..72c2230d1 100644
--- a/src/share/classes/javax/swing/plaf/metal/MetalIconFactory.java
+++ b/src/share/classes/javax/swing/plaf/metal/MetalIconFactory.java
@@ -2278,18 +2278,16 @@ private static class VerticalSliderThumbIcon implements Icon, Serializable, UIRe
}
public void paintIcon( Component c, Graphics g, int x, int y ) {
- JSlider slider = (JSlider)c;
-
- boolean leftToRight = MetalUtils.isLeftToRight(slider);
+ boolean leftToRight = MetalUtils.isLeftToRight(c);
g.translate( x, y );
// Draw the frame
- if ( slider.hasFocus() ) {
+ if ( c.hasFocus() ) {
g.setColor( MetalLookAndFeel.getPrimaryControlInfo() );
}
else {
- g.setColor( slider.isEnabled() ? MetalLookAndFeel.getPrimaryControlInfo() :
+ g.setColor( c.isEnabled() ? MetalLookAndFeel.getPrimaryControlInfo() :
MetalLookAndFeel.getControlDarkShadow() );
}
@@ -2309,7 +2307,7 @@ private static class VerticalSliderThumbIcon implements Icon, Serializable, UIRe
}
// Fill in the background
- if ( slider.hasFocus() ) {
+ if ( c.hasFocus() ) {
g.setColor( c.getForeground() );
}
else {
@@ -2338,8 +2336,8 @@ private static class VerticalSliderThumbIcon implements Icon, Serializable, UIRe
// Draw the bumps
int offset = (leftToRight) ? 2 : 8;
- if ( slider.isEnabled() ) {
- if ( slider.hasFocus() ) {
+ if ( c.isEnabled() ) {
+ if ( c.hasFocus() ) {
primaryBumps.paintIcon( c, g, offset, 2 );
}
else {
@@ -2348,8 +2346,8 @@ private static class VerticalSliderThumbIcon implements Icon, Serializable, UIRe
}
// Draw the highlight
- if ( slider.isEnabled() ) {
- g.setColor( slider.hasFocus() ? MetalLookAndFeel.getPrimaryControl()
+ if ( c.isEnabled() ) {
+ g.setColor( c.hasFocus() ? MetalLookAndFeel.getPrimaryControl()
: MetalLookAndFeel.getControlHighlight() );
if (leftToRight) {
g.drawLine( 1, 1, 8, 1 );
@@ -2389,16 +2387,14 @@ private static class HorizontalSliderThumbIcon implements Icon, Serializable, UI
}
public void paintIcon( Component c, Graphics g, int x, int y ) {
- JSlider slider = (JSlider)c;
-
g.translate( x, y );
// Draw the frame
- if ( slider.hasFocus() ) {
+ if ( c.hasFocus() ) {
g.setColor( MetalLookAndFeel.getPrimaryControlInfo() );
}
else {
- g.setColor( slider.isEnabled() ? MetalLookAndFeel.getPrimaryControlInfo() :
+ g.setColor( c.isEnabled() ? MetalLookAndFeel.getPrimaryControlInfo() :
MetalLookAndFeel.getControlDarkShadow() );
}
@@ -2409,7 +2405,7 @@ private static class HorizontalSliderThumbIcon implements Icon, Serializable, UI
g.drawLine( 7,15 , 14,8 ); // right slant
// Fill in the background
- if ( slider.hasFocus() ) {
+ if ( c.hasFocus() ) {
g.setColor( c.getForeground() );
}
else {
@@ -2425,8 +2421,8 @@ private static class HorizontalSliderThumbIcon implements Icon, Serializable, UI
g.drawLine( 7,14 , 7,14 );
// Draw the bumps
- if ( slider.isEnabled() ) {
- if ( slider.hasFocus() ) {
+ if ( c.isEnabled() ) {
+ if ( c.hasFocus() ) {
primaryBumps.paintIcon( c, g, 2, 2 );
}
else {
@@ -2435,8 +2431,8 @@ private static class HorizontalSliderThumbIcon implements Icon, Serializable, UI
}
// Draw the highlight
- if ( slider.isEnabled() ) {
- g.setColor( slider.hasFocus() ? MetalLookAndFeel.getPrimaryControl()
+ if ( c.isEnabled() ) {
+ g.setColor( c.hasFocus() ? MetalLookAndFeel.getPrimaryControl()
: MetalLookAndFeel.getControlHighlight() );
g.drawLine( 1, 1, 13, 1 );
g.drawLine( 1, 1, 1, 8 );