APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing.plaf.basic

public Class BasicScrollBarUI

extends ScrollBarUI
implements LayoutManager, SwingConstants
Class Inheritance
All Implemented Interfaces
javax.swing.SwingConstants, java.awt.LayoutManager
Known Direct Subclasses
javax.swing.plaf.metal.MetalScrollBarUI, javax.swing.plaf.synth.SynthScrollBarUI, com.sun.java.swing.plaf.motif.MotifScrollBarUI, sun.awt.X11.XTextAreaPeer.XAWTScrollBarUI
Imports
java.awt.Color, .Component, .Container, .Dimension, .Graphics, .Insets, .LayoutManager, .Point, .Rectangle, java.awt.event.ActionEvent, .ActionListener, .FocusEvent, .FocusListener, .MouseAdapter, .MouseEvent, .MouseMotionListener, java.beans.PropertyChangeEvent, .PropertyChangeListener, javax.swing.BoundedRangeModel, .InputMap, .JButton, .JComponent, .JFrame, .JList, .JScrollBar, .JScrollPane, .JViewport, .LookAndFeel, .SwingConstants, .SwingUtilities, .Timer, .UIManager, javax.swing.event.ChangeEvent, .ChangeListener, javax.swing.plaf.ComponentUI, .ScrollBarUI, .UIResource, sun.swing.DefaultLookup, .UIAction

Implementation of ScrollBarUI for the Basic Look and Feel
Authors
Rich Schiavi, David Kloba, Hans Muller

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
BasicScrollBarUI.Actions

Used for scrolling the scrollbar.

protected class
BasicScrollBarUI.ArrowButtonListener

Listener for cursor keys.

private class
protected class
BasicScrollBarUI.ModelListener

A listener to listen for model changes.

public class
protected class
BasicScrollBarUI.ScrollListener

Listener for scrolling events initiated in the ScrollPane.

protected class

Field Summary

Modifier and TypeField and Description
protected BasicScrollBarUI.ArrowButtonListener
buttonListener

Button listener

protected JButton
decrButton

Decrement button

protected static final int
DECREASE_HIGHLIGHT

Decrease highlight

protected int
decrGap

Distance between the decrement button and the track.

private BasicScrollBarUI.Handler
protected JButton
incrButton

Increment button

protected static final int
INCREASE_HIGHLIGHT

Increase highlight

protected int
incrGap

Distance between the increment button and the track.

protected boolean
isDragging

Dragging

private static final int
protected Dimension
maximumThumbSize

Maximum thumb size

private static final int
protected Dimension
minimumThumbSize

Minimum thumb size

protected BasicScrollBarUI.ModelListener
modelListener

Model listener

private static final int
protected static final int
NO_HIGHLIGHT

No highlight

private static final int
protected PropertyChangeListener
propertyChangeListener

Property change listener

protected JScrollBar
scrollbar

Scrollbar

private int
scrollBarValue

The scrollbar value is cached to save real value if the view is adjusted.

protected int
scrollBarWidth

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

protected BasicScrollBarUI.ScrollListener
scrollListener

Scroll listener

private static final int
protected Timer
scrollTimer

Scroll timer

private boolean
supportsAbsolutePositioning

True indicates a middle click will absolutely position the scrollbar.

private boolean
protected Color
thumbColor

Thumb color

protected Color
thumbDarkShadowColor

Thumb dark shadow color

protected Color
thumbHighlightColor

Thumb highlight color

protected Color
thumbLightShadowColor

Thumb light shadow color

protected Rectangle
thumbRect

Thumb rectangle

protected Color
trackColor

Track color

protected int
trackHighlight

Track highlight

protected Color
trackHighlightColor

Track highlight color

protected BasicScrollBarUI.TrackListener
trackListener

Track listener

protected Rectangle
trackRect

Track rectangle

private boolean
useCachedValue

Determine whether scrollbar layout should use cached value or adjusted value returned by scrollbar's getValue.

Constructor Summary

AccessConstructor and Description
public
BasicScrollBarUI()

Constructs a BasicScrollBarUI.

Method Summary

Modifier and TypeMethod and Description
public void
addLayoutComponent(String name, Component child)

Implements java.awt.LayoutManager.addLayoutComponent.

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()

Configures the scroll bar colors.

protected BasicScrollBarUI.ArrowButtonListener

Returns:

an arrow button listener
createArrowButtonListener
()

Creates an arrow button listener.

protected JButton

Returns:

a decrease button
createDecreaseButton
(int
the orientation
orientation
)

Creates a decrease button.

protected JButton

Returns:

an increase button
createIncreaseButton
(int
the orientation
orientation
)

Creates an increase button.

protected BasicScrollBarUI.ModelListener

Returns:

a model listener
createModelListener
()

Creates a model listener.

protected PropertyChangeListener

Returns:

a property change listener
createPropertyChangeListener
()

Creates a property change listener.

protected BasicScrollBarUI.ScrollListener

Returns:

a scroll listener
createScrollListener
()

Creates a scroll listener.

protected BasicScrollBarUI.TrackListener

Returns:

a track listener
createTrackListener
()

Creates a track listener.

public static ComponentUI

Returns:

the UI
createUI
(JComponent
the component
c
)

Hides javax.swing.plaf.ComponentUI.createUI.

Creates the UI.

private BasicScrollBarUI.Handler
private InputMap
getInputMap(int condition)

public Dimension

Returns:

new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
getMaximumSize
(JComponent
The JScrollBar that's delegating this method to us.
c
)

Overrides javax.swing.plaf.ComponentUI.getMaximumSize.

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

protected Dimension

Returns:

The largest acceptable size for the thumb.
getMaximumThumbSize
()

Returns the largest acceptable size for the thumb.

protected Dimension

Returns:

The smallest acceptable size for the thumb.
getMinimumThumbSize
()

Returns the smallest acceptable size for the thumb.

public Dimension

Returns:

the preferred size of a Basic JScrollBar
getPreferredSize
(JComponent
the JScrollBar that's delegating this method to us
c
)

Overrides javax.swing.plaf.ComponentUI.getPreferredSize.

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.

public boolean

Returns:

true if a mouse gesture can absolutely position the thumb
getSupportsAbsolutePositioning
()

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

protected Rectangle

Returns:

The current size/location of the thumb.
getThumbBounds
()

Return the current size/location of the thumb.

protected Rectangle

Returns:

the current bounds of the scrollbar track
getTrackBounds
()

Returns the current bounds of the track, i.e. the space in between the increment and decrement buttons, less the insets.

private int
protected void
installComponents()

Installs the components.

protected void
installDefaults()

Installs the defaults.

protected void
installKeyboardActions()

Installs the keyboard actions.

protected void
installListeners()

Installs the listeners.

public void
installUI(JComponent
the component
c
)

Overrides javax.swing.plaf.ComponentUI.installUI.

Installs the UI.

private boolean
private boolean
private boolean
private boolean
public boolean

Returns:

true if the thumb is currently active
isThumbRollover
()

Returns true if the mouse is currently over the thumb.

public void
layoutContainer(Container scrollbarContainer)

Implements java.awt.LayoutManager.layoutContainer.

Lays out the specified container.

protected void
layoutHScrollbar(JScrollBar
the scroll bar
sb
)

Lays out a horizontal scroll bar.

protected void
layoutVScrollbar(JScrollBar
the scroll bar
sb
)

Lays out a vertical scroll bar.

pack-priv static void
public Dimension
minimumLayoutSize(Container scrollbarContainer)

Implements java.awt.LayoutManager.minimumLayoutSize.

Calculates the minimum size dimensions for the specified container, given the components it contains.

public void
paint(Graphics g, JComponent c)

Overrides javax.swing.plaf.ComponentUI.paint.

Paints the specified component appropriately for the look and feel.

protected void
paintDecreaseHighlight(Graphics
the graphics
g
)

Paints the decrease highlight.

protected void
paintIncreaseHighlight(Graphics
the graphics
g
)

Paints the increase highlight.

protected void
paintThumb(Graphics
the graphics
g
,
JComponent
the component
c
,
Rectangle
the thumb bounds
thumbBounds
)

Paints the thumb.

protected void
paintTrack(Graphics
the graphics
g
,
JComponent
the component
c
,
Rectangle
the track bounds
trackBounds
)

Paints the track.

public Dimension
preferredLayoutSize(Container scrollbarContainer)

Implements java.awt.LayoutManager.preferredLayoutSize.

Calculates the preferred size dimensions for the specified container, given the components it contains.

public void
removeLayoutComponent(Component child)

Implements java.awt.LayoutManager.removeLayoutComponent.

Removes the specified component from the layout.

pack-priv static void
scrollByBlock(JScrollBar scrollbar, int direction)

protected void
scrollByBlock(int
the direction to scroll
direction
)

Scrolls by block.

protected void
scrollByUnit(int
the direction to scroll
direction
)

Scrolls by unit.

pack-priv static void
scrollByUnits(JScrollBar scrollbar, int direction, int units, boolean limitToBlock)

private void
setDragging(boolean dragging)

protected void
setThumbBounds(int
set the x location of the thumb
x
,
int
set the y location of the thumb
y
,
int
set the width of the thumb
width
,
int
set the height of the thumb
height
)

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

protected void
setThumbRollover(boolean
True indicates the thumb is currently active.
active
)

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

private void
protected void
uninstallComponents()

Uninstalls the components.

protected void
uninstallDefaults()

Uninstalls the defaults.

protected void
uninstallKeyboardActions()

Uninstalls the keyboard actions.

protected void
uninstallListeners()

Uninstall the listeners.

public void
uninstallUI(JComponent
the component
c
)

Overrides javax.swing.plaf.ComponentUI.uninstallUI.

Uninstalls the UI.

private void
private void
updateThumbState(int x, int y)