public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager, SwingConstants
Implementation of ScrollBarUI for the Basic Look and Feel
Modifier and Type | Class and Description |
---|---|
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 |
protected class |
BasicScrollBarUI.TrackListener Track mouse drags. |
protected Dimension minimumThumbSize
protected Dimension maximumThumbSize
protected Color thumbHighlightColor
protected Color thumbLightShadowColor
protected Color thumbDarkShadowColor
protected Color thumbColor
protected Color trackColor
protected Color trackHighlightColor
protected JScrollBar scrollbar
protected JButton incrButton
protected JButton decrButton
protected boolean isDragging
protected BasicScrollBarUI.TrackListener trackListener
protected BasicScrollBarUI.ArrowButtonListener buttonListener
protected BasicScrollBarUI.ModelListener modelListener
protected Rectangle thumbRect
protected Rectangle trackRect
protected int trackHighlight
protected static final int NO_HIGHLIGHT
protected static final int DECREASE_HIGHLIGHT
protected static final int INCREASE_HIGHLIGHT
protected BasicScrollBarUI.ScrollListener scrollListener
protected PropertyChangeListener propertyChangeListener
protected Timer scrollTimer
protected int scrollBarWidth
Hint as to what width (when vertical) or height (when horizontal) should be.
protected int incrGap
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.
protected int decrGap
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.
public BasicScrollBarUI()
public static ComponentUI createUI(JComponent c)
protected void configureScrollBarColors()
public void installUI(JComponent c)
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:
LayoutManager
on the component if necessary. PropertyChangeListener
on the component in order to detect and respond to component property changes appropriately. installUI
in class ComponentUI
c
- the component where this UI delegate is being installedComponentUI.uninstallUI(javax.swing.JComponent)
, JComponent.setUI(javax.swing.plaf.ComponentUI)
, JComponent.updateUI()
public void uninstallUI(JComponent c)
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:
uninstallUI
in class ComponentUI
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 componentsComponentUI.installUI(javax.swing.JComponent)
, JComponent.updateUI()
protected void installDefaults()
protected void installComponents()
protected void uninstallComponents()
protected void installListeners()
protected void installKeyboardActions()
protected void uninstallKeyboardActions()
protected void uninstallListeners()
protected void uninstallDefaults()
protected BasicScrollBarUI.TrackListener createTrackListener()
protected BasicScrollBarUI.ArrowButtonListener createArrowButtonListener()
protected BasicScrollBarUI.ModelListener createModelListener()
protected BasicScrollBarUI.ScrollListener createScrollListener()
protected PropertyChangeListener createPropertyChangeListener()
protected void setThumbRollover(boolean active)
Sets whether or not the mouse is currently over the thumb.
active
- True indicates the thumb is currently active.public boolean isThumbRollover()
Returns true if the mouse is currently over the thumb.
public void paint(Graphics g, JComponent c)
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.
paint
in class ComponentUI
g
- the Graphics
context in which to paintc
- the component being painted; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple componentsComponentUI.update(java.awt.Graphics, javax.swing.JComponent)
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.
getPreferredSize
in class ComponentUI
c
- the JScrollBar
that's delegating this method to usgetMaximumSize(javax.swing.JComponent)
, ComponentUI.getMinimumSize(javax.swing.JComponent)
public Dimension getMaximumSize(JComponent c)
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.
getMaximumSize
in class ComponentUI
c
- The JScrollBar that's delegating this method to us.ComponentUI.getMinimumSize(javax.swing.JComponent)
, getPreferredSize(javax.swing.JComponent)
protected JButton createDecreaseButton(int orientation)
protected JButton createIncreaseButton(int orientation)
protected void paintDecreaseHighlight(Graphics g)
protected void paintIncreaseHighlight(Graphics g)
protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds)
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds)
protected Dimension getMinimumThumbSize()
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.
getMaximumThumbSize()
protected Dimension getMaximumThumbSize()
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.
getMinimumThumbSize()
public void addLayoutComponent(String name, Component child)
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
.
addLayoutComponent
in interface LayoutManager
name
- the string to be associated with the componentchild
- the component to be addedpublic void removeLayoutComponent(Component child)
Description copied from interface: LayoutManager
Removes the specified component from the layout.
removeLayoutComponent
in interface LayoutManager
child
- the component to be removedpublic Dimension preferredLayoutSize(Container scrollbarContainer)
Description copied from interface: LayoutManager
Calculates the preferred size dimensions for the specified container, given the components it contains.
preferredLayoutSize
in interface LayoutManager
scrollbarContainer
- the container to be laid outLayoutManager.minimumLayoutSize(java.awt.Container)
public Dimension minimumLayoutSize(Container scrollbarContainer)
Description copied from interface: LayoutManager
Calculates the minimum size dimensions for the specified container, given the components it contains.
minimumLayoutSize
in interface LayoutManager
scrollbarContainer
- the component to be laid outLayoutManager.preferredLayoutSize(java.awt.Container)
protected void layoutVScrollbar(JScrollBar sb)
protected void layoutHScrollbar(JScrollBar sb)
public void layoutContainer(Container scrollbarContainer)
Description copied from interface: LayoutManager
Lays out the specified container.
layoutContainer
in interface LayoutManager
scrollbarContainer
- the container to be laid outprotected 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.
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.
setThumbBounds(int, int, int, int)
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.
layoutContainer(java.awt.Container)
protected void scrollByBlock(int direction)
protected void scrollByUnit(int direction)
public boolean getSupportsAbsolutePositioning()
Indicates whether the user can absolutely position the thumb with a mouse gesture (usually the middle mouse button).
© 1993–2017, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.