FileDocCategorySizeDatePackage
WindowsSliderUI.javaAPI DocJava SE 6 API6566Tue Jun 10 00:21:58 BST 2008com.sun.java.swing.plaf.windows

WindowsSliderUI

public class WindowsSliderUI extends BasicSliderUI
Windows rendition of the component.

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.

Fields Summary
private boolean
rollover
private boolean
pressed
Constructors Summary
public WindowsSliderUI(JSlider b)


      
	super(b);
    
Methods Summary
protected TrackListenercreateTrackListener(javax.swing.JSlider slider)
Overrides to return a private track listener subclass which handles the HOT, PRESSED, and FOCUSED states.

since
1.6

        return new WindowsTrackListener();
    
public static javax.swing.plaf.ComponentUIcreateUI(javax.swing.JComponent b)

        return new WindowsSliderUI((JSlider)b);
    
protected java.awt.DimensiongetThumbSize()

        XPStyle xp = XPStyle.getXP();
	if (xp != null) {
            Dimension size = new Dimension();
            Skin s = xp.getSkin(slider, getXPThumbPart());
            size.width = s.getWidth();
            size.height = s.getHeight();
            return size;
	} else {
	    return super.getThumbSize();
	}
    
private PartgetXPThumbPart()

	XPStyle xp = XPStyle.getXP();
	Part part;
        boolean vertical = (slider.getOrientation() == JSlider.VERTICAL);
	boolean leftToRight = slider.getComponentOrientation().isLeftToRight();
	Boolean paintThumbArrowShape =
		(Boolean)slider.getClientProperty("Slider.paintThumbArrowShape");
	if ((!slider.getPaintTicks() && paintThumbArrowShape == null) ||
            paintThumbArrowShape == Boolean.FALSE) {
		part = vertical ? Part.TKP_THUMBVERT
                                : Part.TKP_THUMB;
	} else {
		part = vertical ? (leftToRight ? Part.TKP_THUMBRIGHT : Part.TKP_THUMBLEFT)
                                : Part.TKP_THUMBBOTTOM;
	}
	return part;
    
protected voidpaintMajorTickForHorizSlider(java.awt.Graphics g, java.awt.Rectangle tickBounds, int x)

	XPStyle xp = XPStyle.getXP();
	if (xp != null) {
	    g.setColor(xp.getColor(slider, Part.TKP_TICS, null, Prop.COLOR, Color.black));
	}
	super.paintMajorTickForHorizSlider(g, tickBounds, x);
    
protected voidpaintMajorTickForVertSlider(java.awt.Graphics g, java.awt.Rectangle tickBounds, int y)

	XPStyle xp = XPStyle.getXP();
	if (xp != null) {
	    g.setColor(xp.getColor(slider, Part.TKP_TICSVERT, null, Prop.COLOR, Color.black));
	}
	super.paintMajorTickForVertSlider(g, tickBounds, y);
    
protected voidpaintMinorTickForHorizSlider(java.awt.Graphics g, java.awt.Rectangle tickBounds, int x)

	XPStyle xp = XPStyle.getXP();
	if (xp != null) {
	    g.setColor(xp.getColor(slider, Part.TKP_TICS, null, Prop.COLOR, Color.black));
	}
	super.paintMinorTickForHorizSlider(g, tickBounds, x);
    
protected voidpaintMinorTickForVertSlider(java.awt.Graphics g, java.awt.Rectangle tickBounds, int y)

	XPStyle xp = XPStyle.getXP();
	if (xp != null) {
	    g.setColor(xp.getColor(slider, Part.TKP_TICSVERT, null, Prop.COLOR, Color.black));
	}
	super.paintMinorTickForVertSlider(g, tickBounds, y);
    
public voidpaintThumb(java.awt.Graphics g)

        
	XPStyle xp = XPStyle.getXP();
	if (xp != null) {
	    Part part = getXPThumbPart();
            State state = State.NORMAL;

            if (slider.hasFocus()) {
                state = State.FOCUSED;
            }
            if (rollover) {
                state = State.HOT;
            }
            if (pressed) {
                state = State.PRESSED;
            }
            if(!slider.isEnabled()) {
                state = State.DISABLED;
            }
            
	    xp.getSkin(slider, part).paintSkin(g, thumbRect.x, thumbRect.y, state);
	} else {
	    super.paintThumb(g);
	}
    
public voidpaintTrack(java.awt.Graphics g)

        
	XPStyle xp = XPStyle.getXP();
	if (xp != null) {
	    boolean vertical = (slider.getOrientation() == JSlider.VERTICAL);
	    Part part = vertical ? Part.TKP_TRACKVERT : Part.TKP_TRACK;
	    Skin skin = xp.getSkin(slider, part);

	    if (vertical) {
		int x = (trackRect.width - skin.getWidth()) / 2;
		skin.paintSkin(g, trackRect.x + x, trackRect.y,
			       skin.getWidth(), trackRect.height, null);
	    } else {
		int y = (trackRect.height - skin.getHeight()) / 2;
		skin.paintSkin(g, trackRect.x, trackRect.y + y,
			       trackRect.width, skin.getHeight(), null);
	    }
	} else {
	    super.paintTrack(g);
	}