- java.lang.Object
-
- javax.swing.plaf.ComponentUI
-
- javax.swing.plaf.ScrollBarUI
-
- javax.swing.plaf.basic.BasicScrollBarUI
-
- javax.swing.plaf.metal.MetalScrollBarUI
-
- All Implemented Interfaces:
LayoutManager
,SwingConstants
public class MetalScrollBarUI extends BasicScrollBarUI
Implementation of ScrollBarUI for the Metal Look and Feel
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.plaf.basic.BasicScrollBarUI
BasicScrollBarUI.ArrowButtonListener, BasicScrollBarUI.ModelListener, BasicScrollBarUI.PropertyChangeHandler, BasicScrollBarUI.ScrollListener, BasicScrollBarUI.TrackListener
-
-
Field Summary
Fields Modifier and Type Field Description protected MetalScrollButton
decreaseButton
The decrease button.static String
FREE_STANDING_PROP
The propertyJScrollBar.isFreeStanding
.protected MetalScrollButton
increaseButton
The increase button.protected boolean
isFreeStanding
The value of the propertyJScrollBar.isFreeStanding
.protected int
scrollBarWidth
The width of the scroll bar.-
Fields inherited from class javax.swing.plaf.basic.BasicScrollBarUI
buttonListener, decrButton, DECREASE_HIGHLIGHT, decrGap, incrButton, INCREASE_HIGHLIGHT, incrGap, isDragging, maximumThumbSize, minimumThumbSize, modelListener, NO_HIGHLIGHT, propertyChangeListener, scrollbar, scrollListener, scrollTimer, thumbDarkShadowColor, thumbLightShadowColor, thumbRect, trackColor, trackHighlight, trackHighlightColor, trackListener, 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
Constructors Constructor Description MetalScrollBarUI()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
configureScrollBarColors()
Configures the scroll bar colors.protected JButton
createDecreaseButton(int orientation)
Returns the view that represents the decrease view.protected JButton
createIncreaseButton(int orientation)
Returns the view that represents the increase view.protected PropertyChangeListener
createPropertyChangeListener()
Creates a property change listener.static ComponentUI
createUI(JComponent c)
Constructs a newMetalScrollBarUI
instance.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 (nonnull
) increment/decrement buttons, and the minimum width of the thumb.protected void
installDefaults()
Installs the defaults.protected void
installListeners()
Installs the listeners.protected void
paintThumb(Graphics g, JComponent c, Rectangle thumbBounds)
Paints the thumb.protected void
paintTrack(Graphics g, JComponent c, Rectangle trackBounds)
Paints the track.protected void
setThumbBounds(int x, int y, int width, int height)
This is overridden only to increase the invalid area.-
Methods inherited from class javax.swing.plaf.basic.BasicScrollBarUI
addLayoutComponent, createArrowButtonListener, createModelListener, createScrollListener, createTrackListener, getMaximumSize, getMaximumThumbSize, getSupportsAbsolutePositioning, getThumbBounds, getTrackBounds, installComponents, installKeyboardActions, installUI, isThumbRollover, layoutContainer, layoutHScrollbar, layoutVScrollbar, minimumLayoutSize, paint, paintDecreaseHighlight, paintIncreaseHighlight, preferredLayoutSize, removeLayoutComponent, scrollByBlock, scrollByUnit, setThumbRollover, uninstallComponents, uninstallDefaults, uninstallKeyboardActions, uninstallListeners, uninstallUI
-
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehavior, getMinimumSize, update
-
-
-
-
Field Detail
-
increaseButton
protected MetalScrollButton increaseButton
The increase button.
-
decreaseButton
protected MetalScrollButton decreaseButton
The decrease button.
-
scrollBarWidth
protected int scrollBarWidth
The width of the scroll bar.
-
FREE_STANDING_PROP
public static final String FREE_STANDING_PROP
The propertyJScrollBar.isFreeStanding
.- See Also:
- Constant Field Values
-
isFreeStanding
protected boolean isFreeStanding
The value of the propertyJScrollBar.isFreeStanding
.
-
-
Method Detail
-
createUI
public static ComponentUI createUI(JComponent c)
Constructs a newMetalScrollBarUI
instance.- Parameters:
c
- a component- Returns:
- a new
MetalScrollBarUI
instance
-
installDefaults
protected void installDefaults()
Description copied from class:BasicScrollBarUI
Installs the defaults.- Overrides:
installDefaults
in classBasicScrollBarUI
-
installListeners
protected void installListeners()
Description copied from class:BasicScrollBarUI
Installs the listeners.- Overrides:
installListeners
in classBasicScrollBarUI
-
createPropertyChangeListener
protected PropertyChangeListener createPropertyChangeListener()
Description copied from class:BasicScrollBarUI
Creates a property change listener.- Overrides:
createPropertyChangeListener
in classBasicScrollBarUI
- Returns:
- a property change listener
-
configureScrollBarColors
protected void configureScrollBarColors()
Description copied from class:BasicScrollBarUI
Configures the scroll bar colors.- Overrides:
configureScrollBarColors
in classBasicScrollBarUI
-
getPreferredSize
public Dimension getPreferredSize(JComponent c)
Description copied from class:BasicScrollBarUI
A vertical scrollbar's preferred width is the maximum of preferred widths of the (nonnull
) 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 classBasicScrollBarUI
- Parameters:
c
- theJScrollBar
that's delegating this method to us- Returns:
- the preferred size of a Basic JScrollBar
- See Also:
BasicScrollBarUI.getMaximumSize(javax.swing.JComponent)
,ComponentUI.getMinimumSize(javax.swing.JComponent)
-
createDecreaseButton
protected JButton createDecreaseButton(int orientation)
Returns the view that represents the decrease view.- Overrides:
createDecreaseButton
in classBasicScrollBarUI
- Parameters:
orientation
- the orientation- Returns:
- a decrease button
-
createIncreaseButton
protected JButton createIncreaseButton(int orientation)
Returns the view that represents the increase view.- Overrides:
createIncreaseButton
in classBasicScrollBarUI
- Parameters:
orientation
- the orientation- Returns:
- an increase button
-
paintTrack
protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds)
Description copied from class:BasicScrollBarUI
Paints the track.- Overrides:
paintTrack
in classBasicScrollBarUI
- Parameters:
g
- the graphicsc
- the componenttrackBounds
- the track bounds
-
paintThumb
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds)
Description copied from class:BasicScrollBarUI
Paints the thumb.- Overrides:
paintThumb
in classBasicScrollBarUI
- Parameters:
g
- the graphicsc
- the componentthumbBounds
- the thumb bounds
-
getMinimumThumbSize
protected Dimension getMinimumThumbSize()
Description copied from class:BasicScrollBarUI
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.
- Overrides:
getMinimumThumbSize
in classBasicScrollBarUI
- Returns:
- The smallest acceptable size for the thumb.
- See Also:
BasicScrollBarUI.getMaximumThumbSize()
-
setThumbBounds
protected void setThumbBounds(int x, int y, int width, int height)
This is overridden only to increase the invalid area. This ensures that the "Shadow" below the thumb is invalidated- Overrides:
setThumbBounds
in classBasicScrollBarUI
- Parameters:
x
- set the x location of the thumby
- set the y location of the thumbwidth
- set the width of the thumbheight
- set the height of the thumb- See Also:
BasicScrollBarUI.getThumbBounds()
-
-