This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


javax.swing.plaf.basic
class BasicScrollBarUI

java.lang.Object extended by javax.swing.plaf.ComponentUI extended by javax.swing.plaf.ScrollBarUI extended by javax.swing.plaf.basic.BasicScrollBarUI
All Implemented Interfaces:
LayoutManager, SwingConstants
Direct Known Subclasses:
MetalScrollBarUI

public class BasicScrollBarUI
extends ScrollBarUI
implements LayoutManager, SwingConstants

Implementation of ScrollBarUI for the Basic Look and Feel


Nested Class Summary
protected class

           Listener for cursor keys.
protected class

           A listener to listen for model changes.
 class

          
protected class

           Listener for scrolling events initiated in the ScrollPane.
protected class

           Track mouse drags.
 
Field Summary
protected BasicScrollBarUI.ArrowButtonListener buttonListener
          
protected JButton decrButton
          
protected static int DECREASE_HIGHLIGHT
          
protected JButton incrButton
          
protected static int INCREASE_HIGHLIGHT
          
protected boolean isDragging
          
protected Dimension maximumThumbSize
          
protected Dimension minimumThumbSize
          
protected BasicScrollBarUI.ModelListener modelListener
          
protected static int NO_HIGHLIGHT
          
protected PropertyChangeListener propertyChangeListener
          
protected JScrollBar scrollbar
          
protected BasicScrollBarUI.ScrollListener scrollListener
          
protected Timer scrollTimer
          
protected Color thumbColor
          
protected Color thumbDarkShadowColor
          
protected Color thumbHighlightColor
          
protected Color thumbLightShadowColor
          
protected Rectangle thumbRect
          
protected Color trackColor
          
protected int trackHighlight
          
protected Color trackHighlightColor
          
protected BasicScrollBarUI.TrackListener trackListener
          
protected Rectangle trackRect
          
 
Constructor Summary

          
 
Method Summary
 void

          
protected void

          
protected BasicScrollBarUI.ArrowButtonListener

          
protected JButton
createDecreaseButton(int orientation)

          
protected JButton
createIncreaseButton(int orientation)

          
protected BasicScrollBarUI.ModelListener

          
protected PropertyChangeListener

          
protected BasicScrollBarUI.ScrollListener

          
protected BasicScrollBarUI.TrackListener

          
static ComponentUI

          
 Dimension

          Returns the specified component's maximum size appropriate for the look and feel.
protected Dimension

          Return the largest acceptable size for the thumb.
protected Dimension

          Return the smallest acceptable size for the thumb.
 Dimension

          A vertical scrollbar's preferred width is the maximum of preferred widths of the (non null) increment/decrement buttons, and the minimum width of the thumb.
 boolean

          Indicates whether the user can absolutely position the thumb with a mouse gesture (usually the middle mouse button).
protected Rectangle

          Return the current size/location of the thumb.
protected Rectangle

          Returns the current bounds of the track, i.e.
protected void

          
protected void

          
protected void

          
protected void

          
 void

          Configures the specified component appropriate for the look and feel.
 boolean

          Returns true if the mouse is currently over the thumb.
 void
layoutContainer(Container scrollbarContainer)

          
protected void

          
protected void

          
 Dimension
minimumLayoutSize(Container scrollbarContainer)

          
 void

          Paints the specified component appropriate for the look and feel.
protected void

          
protected void

          
protected void
paintThumb(Graphics g, JComponent c, Rectangle thumbBounds)

          
protected void
paintTrack(Graphics g, JComponent c, Rectangle trackBounds)

          
 Dimension
preferredLayoutSize(Container scrollbarContainer)

          
 void

          
protected void
scrollByBlock(int direction)

          
protected void
scrollByUnit(int direction)

          
protected void
setThumbBounds(int x, int y, int width, int height)

          Set the bounds of the thumb and force a repaint that includes the old thumbBounds and the new one.
protected void
setThumbRollover(boolean active)

          Sets whether or not the mouse is currently over the thumb.
protected void

          
protected void

          
protected void

          
protected void

          
 void

          Reverses configuration which was done on the specified component during installUI.
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, createUI, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehavior, getMaximumSize, getMinimumSize, getPreferredSize, installUI, paint, uninstallUI, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buttonListener

protected BasicScrollBarUI.ArrowButtonListener buttonListener

decrButton

protected JButton decrButton

DECREASE_HIGHLIGHT

protected static final int DECREASE_HIGHLIGHT

incrButton

protected JButton incrButton

INCREASE_HIGHLIGHT

protected static final int INCREASE_HIGHLIGHT

isDragging

protected boolean isDragging

maximumThumbSize

protected Dimension maximumThumbSize

minimumThumbSize

protected Dimension minimumThumbSize

modelListener

protected BasicScrollBarUI.ModelListener modelListener

NO_HIGHLIGHT

protected static final int NO_HIGHLIGHT

propertyChangeListener

protected PropertyChangeListener propertyChangeListener

scrollbar

protected JScrollBar scrollbar

scrollListener

protected BasicScrollBarUI.ScrollListener scrollListener

scrollTimer

protected Timer scrollTimer

thumbColor

protected Color thumbColor

thumbDarkShadowColor

protected Color thumbDarkShadowColor

thumbHighlightColor

protected Color thumbHighlightColor

thumbLightShadowColor

protected Color thumbLightShadowColor

thumbRect

protected Rectangle thumbRect

trackColor

protected Color trackColor

trackHighlight

protected int trackHighlight

trackHighlightColor

protected Color trackHighlightColor

trackListener

protected BasicScrollBarUI.TrackListener trackListener

trackRect

protected Rectangle trackRect
Constructor Detail

BasicScrollBarUI

public BasicScrollBarUI()
Method Detail

addLayoutComponent

public void addLayoutComponent(String name,
                               Component child)
Parameters:
name
child

configureScrollBarColors

protected void configureScrollBarColors()

createArrowButtonListener

protected BasicScrollBarUI.ArrowButtonListener createArrowButtonListener()

createDecreaseButton

protected JButton createDecreaseButton(int orientation)
Parameters:
orientation

createIncreaseButton

protected JButton createIncreaseButton(int orientation)
Parameters:
orientation

createModelListener

protected BasicScrollBarUI.ModelListener createModelListener()

createPropertyChangeListener

protected PropertyChangeListener createPropertyChangeListener()

createScrollListener

protected BasicScrollBarUI.ScrollListener createScrollListener()

createTrackListener

protected BasicScrollBarUI.TrackListener createTrackListener()

createUI

public static ComponentUI createUI(JComponent c)
Parameters:
c

getMaximumSize

public Dimension getMaximumSize(JComponent c)
Overrides:
getMaximumSize in class ComponentUI
Parameters:
c - The JScrollBar that's delegating this method to us.
Returns:
new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);

getMaximumThumbSize

protected Dimension getMaximumThumbSize()
Return the largest acceptable size for the thumb. To create a fixed size thumb one make this method and getMinimumThumbSize return the same value.

Warning : the value returned by this method should not be be modified, it's a shared static constant.

Returns:
The largest acceptable size for the thumb.

getMinimumThumbSize

protected Dimension getMinimumThumbSize()
Return the smallest acceptable size for the thumb. If the scrollbar becomes so small that this size isn't available, the thumb will be hidden.

Warning : the value returned by this method should not be be modified, it's a shared static constant.

Returns:
The smallest acceptable size for the thumb.

getPreferredSize

public Dimension getPreferredSize(JComponent c)
A vertical scrollbar's preferred width is the maximum of preferred widths of the (non null) increment/decrement buttons, and the minimum width of the thumb. The preferred height is the sum of the preferred heights of the same parts. The basis for the preferred size of a horizontal scrollbar is similar.

The preferredSize is only computed once, subsequent calls to this method just return a cached size.

Overrides:
getPreferredSize in class ComponentUI
Parameters:
c - the JScrollBar that's delegating this method to us
Returns:
the preferred size of a Basic JScrollBar

getSupportsAbsolutePositioning

public boolean getSupportsAbsolutePositioning()
Indicates whether the user can absolutely position the thumb with a mouse gesture (usually the middle mouse button).

Returns:
true if a mouse gesture can absolutely position the thumb

getThumbBounds

protected Rectangle getThumbBounds()
Return the current size/location of the thumb.

Warning : the value returned by this method should not be be modified, it's a reference to the actual rectangle, not a copy.

Returns:
The current size/location of the thumb.

getTrackBounds

protected Rectangle getTrackBounds()
Returns the current bounds of the track, i.e. the space in between the increment and decrement buttons, less the insets. The value returned by this method is updated each time the scrollbar is laid out (validated).

Warning : the value returned by this method should not be be modified, it's a reference to the actual rectangle, not a copy.

Returns:
the current bounds of the scrollbar track

installComponents

protected void installComponents()

installDefaults

protected void installDefaults()

installKeyboardActions

protected void installKeyboardActions()

installListeners

protected void installListeners()

installUI

public void installUI(JComponent c)
Overrides:
installUI in class ComponentUI
Parameters:
c

isThumbRollover

public boolean isThumbRollover()
Returns true if the mouse is currently over the thumb.

Returns:
true if the thumb is currently active

layoutContainer

public void layoutContainer(Container scrollbarContainer)
Parameters:
scrollbarContainer

layoutHScrollbar

protected void layoutHScrollbar(JScrollBar sb)
Parameters:
sb

layoutVScrollbar

protected void layoutVScrollbar(JScrollBar sb)
Parameters:
sb

minimumLayoutSize

public Dimension minimumLayoutSize(Container scrollbarContainer)
Parameters:
scrollbarContainer

paint

public void paint(Graphics g,
                  JComponent c)
Overrides:
paint in class ComponentUI
Parameters:
g
c

paintDecreaseHighlight

protected void paintDecreaseHighlight(Graphics g)
Parameters:
g

paintIncreaseHighlight

protected void paintIncreaseHighlight(Graphics g)
Parameters:
g

paintThumb

protected void paintThumb(Graphics g,
                          JComponent c,
                          Rectangle thumbBounds)
Parameters:
g
c
thumbBounds

paintTrack

protected void paintTrack(Graphics g,
                          JComponent c,
                          Rectangle trackBounds)
Parameters:
g
c
trackBounds

preferredLayoutSize

public Dimension preferredLayoutSize(Container scrollbarContainer)
Parameters:
scrollbarContainer

removeLayoutComponent

public void removeLayoutComponent(Component child)
Parameters:
child

scrollByBlock

protected void scrollByBlock(int direction)
Parameters:
direction

scrollByUnit

protected void scrollByUnit(int direction)
Parameters:
direction

setThumbBounds

protected void setThumbBounds(int x,
                              int y,
                              int width,
                              int height)
Set the bounds of the thumb and force a repaint that includes the old thumbBounds and the new one.

Parameters:
x
y
width
height

setThumbRollover

protected void setThumbRollover(boolean active)
Sets whether or not the mouse is currently over the thumb.

Parameters:
active - True indicates the thumb is currently active.

uninstallComponents

protected void uninstallComponents()

uninstallDefaults

protected void uninstallDefaults()

uninstallKeyboardActions

protected void uninstallKeyboardActions()

uninstallListeners

protected void uninstallListeners()

uninstallUI

public void uninstallUI(JComponent c)
Overrides:
uninstallUI in class ComponentUI
Parameters:
c


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.