javax.swing.plaf.basic
public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager, SwingConstants
Modifier and Type | Class and Description |
---|---|
protected class |
BasicScrollBarUI.ArrowButtonListener
A helper class that listens to the two JButtons on each end of the
JScrollBar.
|
protected class |
BasicScrollBarUI.ModelListener
A helper class that listens to the ScrollBar's model for ChangeEvents.
|
class |
BasicScrollBarUI.PropertyChangeHandler
A helper class that listens to the ScrollBar's properties.
|
protected class |
BasicScrollBarUI.ScrollListener
A helper class that listens for events from the timer that is used to
move the thumb.
|
protected class |
BasicScrollBarUI.TrackListener
Helper class that listens for movement on the track.
|
Modifier and Type | Field and Description |
---|---|
protected BasicScrollBarUI.ArrowButtonListener |
buttonListener
The listener that listens to the JButtons.
|
protected JButton |
decrButton
The JButton that decrements the scrollbar's value.
|
protected static int |
DECREASE_HIGHLIGHT
Indicates that the decrease highlight should be painted.
|
protected JButton |
incrButton
The JButton that increments the scrollbar's value.
|
protected static int |
INCREASE_HIGHLIGHT
Indicates that the increase highlight should be painted.
|
protected boolean |
isDragging
FIXME: Use this for something (presumably mouseDragged)
|
protected Dimension |
maximumThumbSize
The dimensions of the maximum thumb size.
|
protected Dimension |
minimumThumbSize
The dimensions of the minimum thumb size.
|
protected BasicScrollBarUI.ModelListener |
modelListener
The listener that listens to the model.
|
protected static int |
NO_HIGHLIGHT
Indicates that no highlight should be painted.
|
protected PropertyChangeListener |
propertyChangeListener
The listener that listens to the scrollbar for property changes.
|
protected JScrollBar |
scrollbar
The scrollbar this UI is acting for.
|
protected BasicScrollBarUI.ScrollListener |
scrollListener
The listener that listens to the timer.
|
protected Timer |
scrollTimer
The timer used to move the thumb when the mouse is held.
|
protected Color |
thumbColor
The color of the thumb.
|
protected Color |
thumbDarkShadowColor
The outer shadow of the thumb.
|
protected Color |
thumbHighlightColor
The top and left edge color for the thumb.
|
protected Color |
thumbLightShadowColor
The outer light shadow for the thumb.
|
protected Rectangle |
thumbRect
The size and position of the thumb.
|
protected Color |
trackColor
The color of the track.
|
protected int |
trackHighlight
The current highlight status.
|
protected Color |
trackHighlightColor
The color that is used when the mouse press occurs in the track.
|
protected BasicScrollBarUI.TrackListener |
trackListener
The listener that listens for MouseEvents on the track.
|
protected Rectangle |
trackRect
The size and position of the track.
|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
Constructor and Description |
---|
BasicScrollBarUI() |
Modifier and Type | Method and Description |
---|---|
void |
addLayoutComponent(String name,
Component child)
This method adds a component to the layout.
|
protected void |
configureScrollBarColors()
This method configures the scrollbar's colors.
|
protected BasicScrollBarUI.ArrowButtonListener |
createArrowButtonListener()
This method creates an ArrowButtonListener.
|
protected JButton |
createDecreaseButton(int orientation)
This method creates a new JButton with the appropriate icon for the
orientation.
|
protected JButton |
createIncreaseButton(int orientation)
This method creates a new JButton with the appropriate icon for the
orientation.
|
protected BasicScrollBarUI.ModelListener |
createModelListener()
This method creates a new ModelListener.
|
protected PropertyChangeListener |
createPropertyChangeListener()
This method creates a new PropertyChangeListener.
|
protected BasicScrollBarUI.ScrollListener |
createScrollListener()
This method creates a new ScrollListener.
|
protected BasicScrollBarUI.TrackListener |
createTrackListener()
This method creates a new TrackListener.
|
static ComponentUI |
createUI(JComponent c)
This method returns a new BasicScrollBarUI.
|
Dimension |
getMaximumSize(JComponent c)
This method returns the maximum size for this JComponent.
|
protected Dimension |
getMaximumThumbSize()
This method returns the maximum thumb size.
|
Dimension |
getMinimumSize(JComponent c)
This method returns the minimum size for this JComponent.
|
protected Dimension |
getMinimumThumbSize()
This method returns the minimum thumb size.
|
Dimension |
getPreferredSize(JComponent c)
This method returns a cached value of the preferredSize.
|
boolean |
getSupportsAbsolutePositioning()
Indicates whether the user can position the thumb with
a mouse click (i.e. middle button).
|
protected Rectangle |
getThumbBounds()
This method returns the thumb's bounds based on the current value of the
scrollbar.
|
protected Rectangle |
getTrackBounds()
This method calculates the bounds of the track.
|
protected void |
installComponents()
This method installs any addition Components that are a part of or
related to this scrollbar.
|
protected void |
installDefaults()
This method installs the defaults for the scrollbar specified by the
Basic Look and Feel.
|
protected void |
installKeyboardActions()
Installs the input map from the look and feel defaults, and a
corresponding action map.
|
protected void |
installListeners()
This method installs any listeners for the scrollbar.
|
void |
installUI(JComponent c)
This method installs the UI for the component.
|
boolean |
isThumbRollover()
Returns true if the mouse is over the thumb.
|
void |
layoutContainer(Container scrollbarContainer)
This method lays out the scrollbar.
|
protected void |
layoutHScrollbar(JScrollBar sb)
This method lays out the scrollbar horizontally.
|
protected void |
layoutVScrollbar(JScrollBar sb)
This method lays out the scrollbar vertically.
|
Dimension |
minimumLayoutSize(Container scrollbarContainer)
This method returns the minimum size required for the layout.
|
void |
paint(Graphics g,
JComponent c)
This method is called when the component is painted.
|
protected void |
paintDecreaseHighlight(Graphics g)
This method is called when repainting and the mouse is pressed in the
track.
|
protected void |
paintIncreaseHighlight(Graphics g)
This method is called when repainting and the mouse is pressed in the
track.
|
protected void |
paintThumb(Graphics g,
JComponent c,
Rectangle thumbBounds)
This method paints the thumb.
|
protected void |
paintTrack(Graphics g,
JComponent c,
Rectangle trackBounds)
This method paints the track.
|
Dimension |
preferredLayoutSize(Container scrollbarContainer)
This method returns the preferred size for the layout.
|
void |
removeLayoutComponent(Component child)
This method removes a child component from the layout.
|
protected void |
scrollByBlock(int direction)
The method scrolls the thumb by a block in the direction specified.
|
protected void |
scrollByUnit(int direction)
The method scrolls the thumb by a unit in the direction specified.
|
protected void |
setThumbBounds(int x,
int y,
int width,
int height)
This method sets the thumb's bounds.
|
protected void |
setThumbRollover(boolean active)
Set thumbRollover to active.
|
protected void |
uninstallComponents()
This method uninstalls any components that are a part of or related to
this scrollbar.
|
protected void |
uninstallDefaults()
This method uninstalls any defaults that this scrollbar acquired from the
Basic Look and Feel defaults.
|
protected void |
uninstallKeyboardActions()
Uninstalls the input map and action map installed by
installKeyboardActions() . |
protected void |
uninstallListeners()
This method uninstalls any listeners that were registered during install.
|
void |
uninstallUI(JComponent c)
This method uninstalls the UI.
|
contains, getAccessibleChild, getAccessibleChildrenCount, update
protected BasicScrollBarUI.ArrowButtonListener buttonListener
protected BasicScrollBarUI.ModelListener modelListener
protected PropertyChangeListener propertyChangeListener
protected BasicScrollBarUI.ScrollListener scrollListener
protected BasicScrollBarUI.TrackListener trackListener
protected JButton decrButton
protected JButton incrButton
protected Dimension maximumThumbSize
protected Dimension minimumThumbSize
protected Color thumbColor
protected Color thumbDarkShadowColor
protected Color thumbHighlightColor
protected Color thumbLightShadowColor
protected Color trackHighlightColor
protected Color trackColor
protected static final int DECREASE_HIGHLIGHT
protected static final int INCREASE_HIGHLIGHT
protected static final int NO_HIGHLIGHT
protected int trackHighlight
protected boolean isDragging
protected Timer scrollTimer
protected JScrollBar scrollbar
public BasicScrollBarUI()
public void addLayoutComponent(String name, Component child)
addLayoutComponent
in interface LayoutManager
name
- The name to associate with the component that is added.child
- The Component to add.protected void configureScrollBarColors()
protected BasicScrollBarUI.ArrowButtonListener createArrowButtonListener()
protected JButton createIncreaseButton(int orientation)
orientation
- The orientation this JButton uses.protected JButton createDecreaseButton(int orientation)
orientation
- The orientation this JButton uses.protected BasicScrollBarUI.ModelListener createModelListener()
protected PropertyChangeListener createPropertyChangeListener()
protected BasicScrollBarUI.ScrollListener createScrollListener()
protected BasicScrollBarUI.TrackListener createTrackListener()
public static ComponentUI createUI(JComponent c)
c
- The JComponent to create a UI for.public Dimension getMaximumSize(JComponent c)
getMaximumSize
in class ComponentUI
c
- The JComponent to measure the maximum size for.protected Dimension getMaximumThumbSize()
public Dimension getMinimumSize(JComponent c)
getMinimumSize
in class ComponentUI
c
- The JComponent to measure the minimum size for.protected Dimension getMinimumThumbSize()
public Dimension getPreferredSize(JComponent c)
getPreferredSize
in class ComponentUI
c
- The JComponent to measure.protected Rectangle getThumbBounds()
protected Rectangle getTrackBounds()
protected void installComponents()
protected void installDefaults()
protected void installKeyboardActions()
JScrollBar
component has the focus, which is rare.protected void uninstallKeyboardActions()
installKeyboardActions()
.protected void installListeners()
public void installUI(JComponent c)
installUI
in class ComponentUI
c
- The JComponent to install.ComponentUI.uninstallUI(javax.swing.JComponent)
,
JComponent.setUI(javax.swing.plaf.ComponentUI)
,
JComponent.updateUI()
public void layoutContainer(Container scrollbarContainer)
layoutContainer
in interface LayoutManager
scrollbarContainer
- The Container to layout.protected void layoutHScrollbar(JScrollBar sb)
sb
- The JScrollBar to layout.protected void layoutVScrollbar(JScrollBar sb)
sb
- The JScrollBar to layout.public Dimension minimumLayoutSize(Container scrollbarContainer)
minimumLayoutSize
in interface LayoutManager
scrollbarContainer
- The Container that is laid out.LayoutManager.preferredLayoutSize(Container)
public void paint(Graphics g, JComponent c)
paint
in class ComponentUI
g
- The Graphics object to paint with.c
- The JComponent to paint.protected void paintDecreaseHighlight(Graphics g)
g
- The Graphics object to paint with.protected void paintIncreaseHighlight(Graphics g)
g
- The Graphics objet to paint with.protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds)
g
- The Graphics object to paint with.c
- The Component that is being painted.thumbBounds
- The thumb bounds.protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds)
g
- The Graphics object to paint with.c
- The JComponent being painted.trackBounds
- The track's bounds.public Dimension preferredLayoutSize(Container scrollbarContainer)
preferredLayoutSize
in interface LayoutManager
scrollbarContainer
- The Container to find a size for.LayoutManager.minimumLayoutSize(Container)
public void removeLayoutComponent(Component child)
removeLayoutComponent
in interface LayoutManager
child
- The child to remove.protected void scrollByBlock(int direction)
direction
- The direction to scroll.protected void scrollByUnit(int direction)
direction
- The direction to scroll.protected void setThumbBounds(int x, int y, int width, int height)
x
- The X position of the thumb.y
- The Y position of the thumb.width
- The width of the thumb.height
- The height of the thumb.protected void uninstallComponents()
protected void uninstallDefaults()
protected void uninstallListeners()
public void uninstallUI(JComponent c)
uninstallUI
in class ComponentUI
c
- The Component to uninstall for.ComponentUI.installUI(javax.swing.JComponent)
,
JComponent.setUI(javax.swing.plaf.ComponentUI)
,
JComponent.updateUI()
public boolean isThumbRollover()
protected void setThumbRollover(boolean active)
active
- - true if the mouse is over the thumb.public boolean getSupportsAbsolutePositioning()