FileDocCategorySizeDatePackage
WindowsScrollBarUI.javaAPI DocJava SE 5 API12733Fri Aug 26 14:54:50 BST 2005com.sun.java.swing.plaf.windows

WindowsScrollBarUI

public class WindowsScrollBarUI extends BasicScrollBarUI
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 Grid
thumbGrid
private Grid
highlightGrid
Constructors Summary
Methods Summary
protected voidconfigureScrollBarColors()

        super.configureScrollBarColors();
	Color color = UIManager.getColor("ScrollBar.trackForeground");
        if (color != null && trackColor != null) {
            thumbGrid = Grid.getGrid(color, trackColor);
        }

	color = UIManager.getColor("ScrollBar.trackHighlightForeground");
        if (color != null && trackHighlightColor != null) {
            highlightGrid = Grid.getGrid(color, trackHighlightColor);
        }
    
protected javax.swing.JButtoncreateDecreaseButton(int orientation)

        return new WindowsArrowButton(orientation,
				    UIManager.getColor("ScrollBar.thumb"),
				    UIManager.getColor("ScrollBar.thumbShadow"),
				    UIManager.getColor("ScrollBar.thumbDarkShadow"),
				    UIManager.getColor("ScrollBar.thumbHighlight"));
    
protected javax.swing.JButtoncreateIncreaseButton(int orientation)

        return new WindowsArrowButton(orientation,
				    UIManager.getColor("ScrollBar.thumb"),
				    UIManager.getColor("ScrollBar.thumbShadow"),
				    UIManager.getColor("ScrollBar.thumbDarkShadow"),
				    UIManager.getColor("ScrollBar.thumbHighlight"));
    
public static javax.swing.plaf.ComponentUIcreateUI(javax.swing.JComponent c)
Creates a UI for a JScrollBar.

param
c the text field
return
the UI

        return new WindowsScrollBarUI();
    
protected voidinstallDefaults()

	super.installDefaults();

	if (XPStyle.getXP() != null) {
	    scrollbar.setBorder(null);
	}
    
protected voidpaintDecreaseHighlight(java.awt.Graphics g)

        if (highlightGrid == null) {
            super.paintDecreaseHighlight(g);
        }
        else {
            Insets insets = scrollbar.getInsets();
            Rectangle thumbR = getThumbBounds();
            int x, y, w, h;

            if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
                x = insets.left;
                y = decrButton.getY() + decrButton.getHeight();
                w = scrollbar.getWidth() - (insets.left + insets.right);
                h = thumbR.y - y;
            } 
            else {
                x = decrButton.getX() + decrButton.getHeight();
                y = insets.top;
                w = thumbR.x - x;
                h = scrollbar.getHeight() - (insets.top + insets.bottom);
            }
            highlightGrid.paint(g, x, y, w, h);
	}
    
protected voidpaintIncreaseHighlight(java.awt.Graphics g)

        if (highlightGrid == null) {
            super.paintDecreaseHighlight(g);
        }
        else {
            Insets insets = scrollbar.getInsets();
            Rectangle thumbR = getThumbBounds();
            int x, y, w, h;

            if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
                x = insets.left;
                y = thumbR.y + thumbR.height;
                w = scrollbar.getWidth() - (insets.left + insets.right);
                h = incrButton.getY() - y;
            }
            else {
                x = thumbR.x + thumbR.width;
                y = insets.top;
                w = incrButton.getX() - x;
                h = scrollbar.getHeight() - (insets.top + insets.bottom);
            }
            highlightGrid.paint(g, x, y, w, h);
        }
    
protected voidpaintThumb(java.awt.Graphics g, javax.swing.JComponent c, java.awt.Rectangle thumbBounds)

	boolean v = (scrollbar.getOrientation() == JScrollBar.VERTICAL);

	XPStyle xp = XPStyle.getXP();
	if (xp != null) {
	    JScrollBar sb = (JScrollBar)c;
	    int index = 0;
	    if (!sb.isEnabled()) {
		index = 3;
	    } else if (isDragging) {
		index = 2;
	    } else if (isThumbRollover()) {
		index = 1;
	    }
	    // Paint thumb
	    XPStyle.Skin skin = xp.getSkin(v ? "scrollbar.thumbbtnvert" : "scrollbar.thumbbtnhorz");
	    skin.paintSkin(g, thumbBounds, index);
	    // Paint gripper
	    skin = xp.getSkin(v ? "scrollbar.grippervert" : "scrollbar.gripperhorz");
	    skin.paintSkin(g,
			   thumbBounds.x + (thumbBounds.width  - skin.getWidth()) / 2,
			   thumbBounds.y + (thumbBounds.height - skin.getHeight()) / 2,
			   skin.getWidth(), skin.getHeight(), index);

	} else {
	    super.paintThumb(g, c, thumbBounds);
	}
    
protected voidpaintTrack(java.awt.Graphics g, javax.swing.JComponent c, java.awt.Rectangle trackBounds)

	boolean v = (scrollbar.getOrientation() == JScrollBar.VERTICAL);

	XPStyle xp = XPStyle.getXP();
	if (xp != null) {
	    JScrollBar sb = (JScrollBar)c;
	    int index = 0;
	    // Pending: Implement rollover 1 and pressed 2
	    if (!sb.isEnabled()) {
		index = 3;
	    }
	    String category = v ? "scrollbar.lowertrackvert" : "scrollbar.lowertrackhorz";
	    xp.getSkin(category).paintSkin(g, trackBounds, index);
	} else if (thumbGrid == null) {
            super.paintTrack(g, c, trackBounds);
        }
        else {
            thumbGrid.paint(g, trackBounds.x, trackBounds.y, trackBounds.width,
                            trackBounds.height);
            if (trackHighlight == DECREASE_HIGHLIGHT) {
                paintDecreaseHighlight(g);
            } 
            else if (trackHighlight == INCREASE_HIGHLIGHT) {
                paintIncreaseHighlight(g);
            }
        }
    
public voiduninstallUI(javax.swing.JComponent c)

        super.uninstallUI(c);
        thumbGrid = highlightGrid = null;