|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.plaf.ComponentUI javax.swing.plaf.ScrollBarUI javax.swing.plaf.basic.BasicScrollBarUI
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 . |
private static class |
BasicScrollBarUI.SharedActionScroller
Used for scrolling the scrollbar. |
protected class |
BasicScrollBarUI.TrackListener
Track mouse drags. |
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()
|
private ActionMap |
createActionMap()
|
protected BasicScrollBarUI.ArrowButtonListener |
createArrowButtonListener()
|
protected JButton |
createDecreaseButton(int orientation)
|
protected JButton |
createIncreaseButton(int orientation)
|
protected BasicScrollBarUI.ModelListener |
createModelListener()
|
protected java.beans.PropertyChangeListener |
createPropertyChangeListener()
|
protected BasicScrollBarUI.ScrollListener |
createScrollListener()
|
protected BasicScrollBarUI.TrackListener |
createTrackListener()
|
static ComponentUI |
createUI(JComponent c)
Returns an instance of the UI delegate for the specified component. |
private ActionMap |
getActionMap()
|
private InputMap |
getInputMap(int condition)
|
Dimension |
getMaximumSize(JComponent c)
Returns the specified component's maximum size appropriate for the look and feel. |
protected Dimension |
getMaximumThumbSize()
Return the largest acceptable size for the thumb. |
Dimension |
getMinimumSize(JComponent c)
A vertical scrollbar's minimum width is the largest minimum width of the (non null ) increment/decrement buttons,
and the minimum width of the thumb. |
protected Dimension |
getMinimumThumbSize()
Return 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. |
private boolean |
getSupportsAbsolutePositioning()
Indicates whether the user can absolutely position the offset with a mouse click (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. the space in between the increment and decrement buttons, less the insets. |
protected void |
installComponents()
|
protected void |
installDefaults()
|
protected void |
installKeyboardActions()
|
protected void |
installListeners()
|
void |
installUI(JComponent c)
Configures the specified component appropriate for the look and feel. |
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 appropriate 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)
|
(package private) static void |
scrollByBlock(JScrollBar scrollbar,
int direction)
|
protected void |
scrollByUnit(int direction)
|
(package private) static void |
scrollByUnits(JScrollBar scrollbar,
int direction,
int units)
|
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 |
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, update |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final int POSITIVE_SCROLL
private static final int NEGATIVE_SCROLL
private static final int MIN_SCROLL
private static final int MAX_SCROLL
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 java.beans.PropertyChangeListener propertyChangeListener
protected Timer scrollTimer
private static final int scrollSpeedThrottle
private boolean supportsAbsolutePositioning
private int scrollBarWidth
Constructor Detail |
public BasicScrollBarUI()
Method Detail |
public static ComponentUI createUI(JComponent c)
ComponentUI
createUI
method that returns an instance of that UI delegate subclass.
If the UI delegate subclass is stateless, it may return an instance
that is shared by multiple components. If the UI delegate is
stateful, then it should return a new instance per component.
The default implementation of this method throws an error, as it
should never be invoked.
protected void configureScrollBarColors()
public void installUI(JComponent c)
ComponentUI
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)
ComponentUI
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()
private InputMap getInputMap(int condition)
private ActionMap getActionMap()
private ActionMap createActionMap()
protected void uninstallListeners()
protected void uninstallDefaults()
protected BasicScrollBarUI.TrackListener createTrackListener()
protected BasicScrollBarUI.ArrowButtonListener createArrowButtonListener()
protected BasicScrollBarUI.ModelListener createModelListener()
protected BasicScrollBarUI.ScrollListener createScrollListener()
protected java.beans.PropertyChangeListener createPropertyChangeListener()
public void paint(Graphics g, JComponent c)
ComponentUI
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)
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 us
getMaximumSize(javax.swing.JComponent)
,
getMinimumSize(javax.swing.JComponent)
public Dimension getMinimumSize(JComponent c)
null
) increment/decrement buttons,
and the minimum width of the thumb. The minimum height is the
sum of the minimum heights of the same parts. The basis for
the preferred size of a horizontal scrollbar is similar.
The minimumSize
is only computed once, subsequent
calls to this method just return a cached size.
getMinimumSize
in class ComponentUI
c
- the JScrollBar
that's delegating this method to us
JScrollBar
getMaximumSize(javax.swing.JComponent)
,
getPreferredSize(javax.swing.JComponent)
public Dimension getMaximumSize(JComponent c)
ComponentUI
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.
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()
Warning : the value returned by this method should not be be modified, it's a shared static constant.
getMaximumThumbSize()
protected Dimension getMaximumThumbSize()
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)
LayoutManager
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)
LayoutManager
removeLayoutComponent
in interface LayoutManager
child
- the component to be removedpublic Dimension preferredLayoutSize(Container scrollbarContainer)
LayoutManager
preferredLayoutSize
in interface LayoutManager
scrollbarContainer
- the container to be laid outLayoutManager.minimumLayoutSize(java.awt.Container)
public Dimension minimumLayoutSize(Container scrollbarContainer)
LayoutManager
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)
LayoutManager
layoutContainer
in interface LayoutManager
scrollbarContainer
- the container to be laid outprotected void setThumbBounds(int x, int y, int width, int height)
getThumbBounds()
protected Rectangle getThumbBounds()
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()
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)
static void scrollByBlock(JScrollBar scrollbar, int direction)
protected void scrollByBlock(int direction)
static void scrollByUnits(JScrollBar scrollbar, int direction, int units)
protected void scrollByUnit(int direction)
private boolean getSupportsAbsolutePositioning()
The return value is determined from the UIManager property ScrollBar.allowsAbsolutePositioning.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |