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, SynthScrollBarUI

public class BasicScrollBarUI
extends ScrollBarUI
implements LayoutManager, SwingConstants

Disabled: no SafeJ information.

Implementation of ScrollBarUI for the Basic Look and Feel


Nested Class Summary
protected  class BasicScrollBarUI.ArrowButtonListener
          Listener for cursor keys.
protected  class BasicScrollBarUI.ModelListener
          A listener to listen for model changes.
 class BasicScrollBarUI.PropertyChangeHandler
           
protected  class BasicScrollBarUI.ScrollListener
          Listener for scrolling events initiated in the ScrollPane.
protected  class BasicScrollBarUI.TrackListener
          Track mouse drags.
 
Field Summary
protected  BasicScrollBarUI.ArrowButtonListener buttonListener
           
protected  JButton decrButton
           
protected static int DECREASE_HIGHLIGHT
           
protected  int decrGap
          Distance between the decrement button and the track.
protected  JButton incrButton
           
protected static int INCREASE_HIGHLIGHT
           
protected  int incrGap
          Distance between the increment button and the track.
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  int scrollBarWidth
          Hint as to what width (when vertical) or height (when horizontal) should be.
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
           
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Constructor Summary
BasicScrollBarUI()
           
 
Method Summary
 void addLayoutComponent(String name, Component child)
          If the layout manager uses a per-component string, adds the component comp to the layout, associating it with the string specified by name.
protected  void configureScrollBarColors()
           
protected  BasicScrollBarUI.ArrowButtonListener createArrowButtonListener()
           
protected  JButton createDecreaseButton(int orientation)
           
protected  JButton createIncreaseButton(int orientation)
           
protected  BasicScrollBarUI.ModelListener createModelListener()
           
protected  PropertyChangeListener createPropertyChangeListener()
           
protected  BasicScrollBarUI.ScrollListener createScrollListener()
           
protected  BasicScrollBarUI.TrackListener createTrackListener()
           
static ComponentUI createUI(JComponent c)
           
 Dimension getMaximumSize(JComponent c)
          Returns the specified component's maximum size appropriate for the look and feel.
protected  Dimension getMaximumThumbSize()
          Returns the largest acceptable size for the thumb.
protected  Dimension getMinimumThumbSize()
          Returns the smallest acceptable size for the thumb.
 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.
 boolean getSupportsAbsolutePositioning()
          Indicates whether the user can absolutely position the thumb with a mouse gesture (usually the middle mouse button).
protected  Rectangle getThumbBounds()
          Return the current size/location of the thumb.
protected  Rectangle getTrackBounds()
          Returns the current bounds of the track, i.e.
protected  void installComponents()
           
protected  void installDefaults()
           
protected  void installKeyboardActions()
           
protected  void installListeners()
           
 void installUI(JComponent c)
          Configures the specified component appropriately for the look and feel.
 boolean isThumbRollover()
          Returns true if the mouse is currently over the thumb.
 void layoutContainer(Container scrollbarContainer)
          Lays out the specified container.
protected  void layoutHScrollbar(JScrollBar sb)
           
protected  void layoutVScrollbar(JScrollBar sb)
           
 Dimension minimumLayoutSize(Container scrollbarContainer)
          Calculates the minimum size dimensions for the specified container, given the components it contains.
 void paint(Graphics g, JComponent c)
          Paints the specified component appropriately for the look and feel.
protected  void paintDecreaseHighlight(Graphics g)
           
protected  void paintIncreaseHighlight(Graphics g)
           
protected  void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds)
           
protected  void paintTrack(Graphics g, JComponent c, Rectangle trackBounds)
           
 Dimension preferredLayoutSize(Container scrollbarContainer)
          Calculates the preferred size dimensions for the specified container, given the components it contains.
 void removeLayoutComponent(Component child)
          Removes the specified component from the layout.
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 uninstallComponents()
           
protected  void uninstallDefaults()
           
protected  void uninstallKeyboardActions()
           
protected  void uninstallListeners()
           
 void uninstallUI(JComponent c)
          Reverses configuration which was done on the specified component during installUI.
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehavior, getMinimumSize, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

minimumThumbSize

protected Dimension minimumThumbSize
Class is disabled.


maximumThumbSize

protected Dimension maximumThumbSize
Class is disabled.


thumbHighlightColor

protected Color thumbHighlightColor
Class is disabled.


thumbLightShadowColor

protected Color thumbLightShadowColor
Class is disabled.


thumbDarkShadowColor

protected Color thumbDarkShadowColor
Class is disabled.


thumbColor

protected Color thumbColor
Class is disabled.


trackColor

protected Color trackColor
Class is disabled.


trackHighlightColor

protected Color trackHighlightColor
Class is disabled.


scrollbar

protected JScrollBar scrollbar
Class is disabled.


incrButton

protected JButton incrButton
Class is disabled.


decrButton

protected JButton decrButton
Class is disabled.


isDragging

protected boolean isDragging
Class is disabled.


trackListener

protected BasicScrollBarUI.TrackListener trackListener
Class is disabled.


buttonListener

protected BasicScrollBarUI.ArrowButtonListener buttonListener
Class is disabled.


modelListener

protected BasicScrollBarUI.ModelListener modelListener
Class is disabled.


thumbRect

protected Rectangle thumbRect
Class is disabled.


trackRect

protected Rectangle trackRect
Class is disabled.


trackHighlight

protected int trackHighlight
Class is disabled.


NO_HIGHLIGHT

protected static final int NO_HIGHLIGHT
Class is disabled.

See Also:
Constant Field Values

DECREASE_HIGHLIGHT

protected static final int DECREASE_HIGHLIGHT
Class is disabled.

See Also:
Constant Field Values

INCREASE_HIGHLIGHT

protected static final int INCREASE_HIGHLIGHT
Class is disabled.

See Also:
Constant Field Values

scrollListener

protected BasicScrollBarUI.ScrollListener scrollListener
Class is disabled.


propertyChangeListener

protected PropertyChangeListener propertyChangeListener
Class is disabled.


scrollTimer

protected Timer scrollTimer
Class is disabled.


scrollBarWidth

protected int scrollBarWidth
Class is disabled.

Hint as to what width (when vertical) or height (when horizontal) should be.

Since:
1.7

incrGap

protected int incrGap
Class is disabled.

Distance between the increment button and the track. This may be a negative number. If negative, then an overlap between the button and track will occur, which is useful for shaped buttons.

Since:
1.7

decrGap

protected int decrGap
Class is disabled.

Distance between the decrement button and the track. This may be a negative number. If negative, then an overlap between the button and track will occur, which is useful for shaped buttons.

Since:
1.7
Constructor Detail

BasicScrollBarUI

public BasicScrollBarUI()
Class is disabled.

Method Detail

createUI

public static ComponentUI createUI(JComponent c)
Class is disabled.


configureScrollBarColors

protected void configureScrollBarColors()
Class is disabled.


installUI

public void installUI(JComponent c)
Class is disabled.

Description copied from class: ComponentUI
Configures the specified component appropriately for the look and feel. This method is invoked when the ComponentUI instance is being installed as the UI delegate on the specified component. This method should completely configure the component for the look and feel, including the following:
  1. Install default property values for color, fonts, borders, icons, opacity, etc. on the component. Whenever possible, property values initialized by the client program should not be overridden.
  2. Install a LayoutManager on the component if necessary.
  3. Create/add any required sub-components to the component.
  4. Create/install event listeners on the component.
  5. Create/install a PropertyChangeListener on the component in order to detect and respond to component property changes appropriately.
  6. Install keyboard UI (mnemonics, traversal, etc.) on the component.
  7. Initialize any appropriate instance data.

Overrides:
installUI in class ComponentUI
Parameters:
c - the component where this UI delegate is being installed
See Also:
ComponentUI.uninstallUI(javax.swing.JComponent), JComponent.setUI(javax.swing.plaf.ComponentUI), JComponent.updateUI()

uninstallUI

public void uninstallUI(JComponent c)
Class is disabled.

Description copied from class: ComponentUI
Reverses configuration which was done on the specified component during installUI. This method is invoked when this UIComponent instance is being removed as the UI delegate for the specified component. This method should undo the configuration performed in installUI, being careful to leave the JComponent instance in a clean state (no extraneous listeners, look-and-feel-specific property objects, etc.). This should include the following:
  1. Remove any UI-set borders from the component.
  2. Remove any UI-set layout managers on the component.
  3. Remove any UI-added sub-components from the component.
  4. Remove any UI-added event/property listeners from the component.
  5. Remove any UI-installed keyboard UI from the component.
  6. Nullify any allocated instance data objects to allow for GC.

Overrides:
uninstallUI in class ComponentUI
Parameters:
c - the component from which this UI delegate is being removed; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components
See Also:
ComponentUI.installUI(javax.swing.JComponent), JComponent.updateUI()

installDefaults

protected void installDefaults()
Class is disabled.


installComponents

protected void installComponents()
Class is disabled.


uninstallComponents

protected void uninstallComponents()
Class is disabled.


installListeners

protected void installListeners()
Class is disabled.


installKeyboardActions

protected void installKeyboardActions()
Class is disabled.


uninstallKeyboardActions

protected void uninstallKeyboardActions()
Class is disabled.


uninstallListeners

protected void uninstallListeners()
Class is disabled.


uninstallDefaults

protected void uninstallDefaults()
Class is disabled.


createTrackListener

protected BasicScrollBarUI.TrackListener createTrackListener()
Class is disabled.


createArrowButtonListener

protected BasicScrollBarUI.ArrowButtonListener createArrowButtonListener()
Class is disabled.


createModelListener

protected BasicScrollBarUI.ModelListener createModelListener()
Class is disabled.


createScrollListener

protected BasicScrollBarUI.ScrollListener createScrollListener()
Class is disabled.


createPropertyChangeListener

protected PropertyChangeListener createPropertyChangeListener()
Class is disabled.


setThumbRollover

protected void setThumbRollover(boolean active)
Class is disabled.

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

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

isThumbRollover

public boolean isThumbRollover()
Class is disabled.

Returns true if the mouse is currently over the thumb.

Returns:
true if the thumb is currently active
Since:
1.5

paint

public void paint(Graphics g,
                  JComponent c)
Class is disabled.

Description copied from class: ComponentUI
Paints the specified component appropriately for the look and feel. This method is invoked from the ComponentUI.update method when the specified component is being painted. Subclasses should override this method and use the specified Graphics object to render the content of the component.

Overrides:
paint in class ComponentUI
Parameters:
g - the Graphics context in which to paint
c - the component being painted; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components
See Also:
ComponentUI.update(java.awt.Graphics, javax.swing.JComponent)

getPreferredSize

public Dimension getPreferredSize(JComponent c)
Class is disabled.

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
See Also:
getMaximumSize(javax.swing.JComponent), ComponentUI.getMinimumSize(javax.swing.JComponent)

getMaximumSize

public Dimension getMaximumSize(JComponent c)
Class is disabled.

Description copied from class: ComponentUI
Returns the specified component's maximum size appropriate for the look and feel. If null is returned, the maximum size will be calculated by the component's layout manager instead (this is the preferred approach for any component with a specific layout manager installed). The default implementation of this method invokes getPreferredSize and returns that value.

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);
See Also:
ComponentUI.getMinimumSize(javax.swing.JComponent), getPreferredSize(javax.swing.JComponent)

createDecreaseButton

protected JButton createDecreaseButton(int orientation)
Class is disabled.


createIncreaseButton

protected JButton createIncreaseButton(int orientation)
Class is disabled.


paintDecreaseHighlight

protected void paintDecreaseHighlight(Graphics g)
Class is disabled.


paintIncreaseHighlight

protected void paintIncreaseHighlight(Graphics g)
Class is disabled.


paintTrack

protected void paintTrack(Graphics g,
                          JComponent c,
                          Rectangle trackBounds)
Class is disabled.


paintThumb

protected void paintThumb(Graphics g,
                          JComponent c,
                          Rectangle thumbBounds)
Class is disabled.


getMinimumThumbSize

protected Dimension getMinimumThumbSize()
Class is disabled.

Returns 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.
See Also:
getMaximumThumbSize()

getMaximumThumbSize

protected Dimension getMaximumThumbSize()
Class is disabled.

Returns 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.
See Also:
getMinimumThumbSize()

addLayoutComponent

public void addLayoutComponent(String name,
                               Component child)
Class is disabled.

Description copied from interface: LayoutManager
If the layout manager uses a per-component string, adds the component comp to the layout, associating it with the string specified by name.

Specified by:
addLayoutComponent in interface LayoutManager
Parameters:
name - the string to be associated with the component
child - the component to be added

removeLayoutComponent

public void removeLayoutComponent(Component child)
Class is disabled.

Description copied from interface: LayoutManager
Removes the specified component from the layout.

Specified by:
removeLayoutComponent in interface LayoutManager
Parameters:
child - the component to be removed

preferredLayoutSize

public Dimension preferredLayoutSize(Container scrollbarContainer)
Class is disabled.

Description copied from interface: LayoutManager
Calculates the preferred size dimensions for the specified container, given the components it contains.

Specified by:
preferredLayoutSize in interface LayoutManager
Parameters:
scrollbarContainer - the container to be laid out
See Also:
LayoutManager.minimumLayoutSize(java.awt.Container)

minimumLayoutSize

public Dimension minimumLayoutSize(Container scrollbarContainer)
Class is disabled.

Description copied from interface: LayoutManager
Calculates the minimum size dimensions for the specified container, given the components it contains.

Specified by:
minimumLayoutSize in interface LayoutManager
Parameters:
scrollbarContainer - the component to be laid out
See Also:
LayoutManager.preferredLayoutSize(java.awt.Container)

layoutVScrollbar

protected void layoutVScrollbar(JScrollBar sb)
Class is disabled.


layoutHScrollbar

protected void layoutHScrollbar(JScrollBar sb)
Class is disabled.


layoutContainer

public void layoutContainer(Container scrollbarContainer)
Class is disabled.

Description copied from interface: LayoutManager
Lays out the specified container.

Specified by:
layoutContainer in interface LayoutManager
Parameters:
scrollbarContainer - the container to be laid out

setThumbBounds

protected void setThumbBounds(int x,
                              int y,
                              int width,
                              int height)
Class is disabled.

Set the bounds of the thumb and force a repaint that includes the old thumbBounds and the new one.

See Also:
getThumbBounds()

getThumbBounds

protected Rectangle getThumbBounds()
Class is disabled.

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.
See Also:
setThumbBounds(int, int, int, int)

getTrackBounds

protected Rectangle getTrackBounds()
Class is disabled.

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
See Also:
layoutContainer(java.awt.Container)

scrollByBlock

protected void scrollByBlock(int direction)
Class is disabled.


scrollByUnit

protected void scrollByUnit(int direction)
Class is disabled.


getSupportsAbsolutePositioning

public boolean getSupportsAbsolutePositioning()
Class is disabled.

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
Since:
1.5