public class BasicSliderUI extends SliderUI
A Basic L&F implementation of SliderUI.
Modifier and Type | Class and Description |
---|---|
class |
BasicSliderUI.ActionScroller As of Java 2 platform v1.3 this undocumented class is no longer used. |
class |
BasicSliderUI.ChangeHandler Data model listener. |
class |
BasicSliderUI.ComponentHandler Listener for resizing events. |
class |
BasicSliderUI.FocusHandler Focus-change listener. |
class |
BasicSliderUI.PropertyChangeHandler |
class |
BasicSliderUI.ScrollListener Scroll-event listener. |
class |
BasicSliderUI.TrackListener Track mouse movements. |
public static final int POSITIVE_SCROLL
public static final int NEGATIVE_SCROLL
public static final int MIN_SCROLL
public static final int MAX_SCROLL
protected Timer scrollTimer
protected JSlider slider
protected Insets focusInsets
protected Insets insetCache
protected boolean leftToRightCache
protected Rectangle focusRect
protected Rectangle contentRect
protected Rectangle labelRect
protected Rectangle tickRect
protected Rectangle trackRect
protected Rectangle thumbRect
protected int trackBuffer
protected BasicSliderUI.TrackListener trackListener
protected ChangeListener changeListener
protected ComponentListener componentListener
protected FocusListener focusListener
protected BasicSliderUI.ScrollListener scrollListener
protected PropertyChangeListener propertyChangeListener
public BasicSliderUI(JSlider b)
protected Color getShadowColor()
protected Color getHighlightColor()
protected Color getFocusColor()
protected boolean isDragging()
Returns true if the user is dragging the slider.
public static ComponentUI createUI(JComponent b)
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(JSlider slider)
protected void uninstallDefaults(JSlider slider)
protected BasicSliderUI.TrackListener createTrackListener(JSlider slider)
protected ChangeListener createChangeListener(JSlider slider)
protected ComponentListener createComponentListener(JSlider slider)
protected FocusListener createFocusListener(JSlider slider)
protected BasicSliderUI.ScrollListener createScrollListener(JSlider slider)
protected PropertyChangeListener createPropertyChangeListener(JSlider slider)
protected void installListeners(JSlider slider)
protected void uninstallListeners(JSlider slider)
protected void installKeyboardActions(JSlider slider)
protected void uninstallKeyboardActions(JSlider slider)
public int getBaseline(JComponent c, int width, int height)
Returns the baseline.
getBaseline
in class ComponentUI
c
- JComponent
baseline is being requested forwidth
- the width to get the baseline forheight
- the height to get the baseline forNullPointerException
- if c
is null
IllegalArgumentException
- if width or height is < 0JComponent.getBaseline(int, int)
public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
Returns an enum indicating how the baseline of the component changes as the size changes.
getBaselineResizeBehavior
in class ComponentUI
c
- JComponent
to return baseline resize behavior forNullPointerException
- if c
is null
JComponent.getBaseline(int, int)
protected boolean labelsHaveSameBaselines()
Returns true if all the labels from the label table have the same baseline.
public Dimension getPreferredHorizontalSize()
public Dimension getPreferredVerticalSize()
public Dimension getMinimumHorizontalSize()
public Dimension getMinimumVerticalSize()
public Dimension getPreferredSize(JComponent c)
Description copied from class: ComponentUI
Returns the specified component's preferred size appropriate for the look and feel. If null
is returned, the preferred 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 returns null
.
getPreferredSize
in class ComponentUI
c
- the component whose preferred size is being queried; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple componentsJComponent.getPreferredSize()
, LayoutManager.preferredLayoutSize(java.awt.Container)
public Dimension getMinimumSize(JComponent c)
Description copied from class: ComponentUI
Returns the specified component's minimum size appropriate for the look and feel. If null
is returned, the minimum 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.
getMinimumSize
in class ComponentUI
c
- the component whose minimum size is being queried; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple componentsDimension
object or null
JComponent.getMinimumSize()
, LayoutManager.minimumLayoutSize(java.awt.Container)
, ComponentUI.getPreferredSize(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 component whose maximum size is being queried; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple componentsDimension
object or null
JComponent.getMaximumSize()
, LayoutManager2.maximumLayoutSize(java.awt.Container)
protected void calculateGeometry()
protected void calculateFocusRect()
protected void calculateThumbSize()
protected void calculateContentRect()
protected void calculateThumbLocation()
protected void calculateTrackBuffer()
protected void calculateTrackRect()
protected int getTickLength()
Gets the height of the tick area for horizontal sliders and the width of the tick area for vertical sliders. BasicSliderUI uses the returned value to determine the tick area rectangle. If you want to give your ticks some room, make this larger than you need and paint your ticks away from the sides in paintTicks().
protected void calculateTickRect()
protected void calculateLabelRect()
protected Dimension getThumbSize()
protected int getWidthOfWidestLabel()
protected int getHeightOfTallestLabel()
protected int getWidthOfHighValueLabel()
protected int getWidthOfLowValueLabel()
protected int getHeightOfHighValueLabel()
protected int getHeightOfLowValueLabel()
protected boolean drawInverted()
protected Integer getHighestValue()
Returns the biggest value that has an entry in the label table.
protected Integer getLowestValue()
Returns the smallest value that has an entry in the label table.
protected Component getLowestValueLabel()
Returns the label that corresponds to the highest slider value in the label table.
protected Component getHighestValueLabel()
Returns the label that corresponds to the lowest slider value in the label table.
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)
protected void recalculateIfInsetsChanged()
protected void recalculateIfOrientationChanged()
public void paintFocus(Graphics g)
public void paintTrack(Graphics g)
public void paintTicks(Graphics g)
protected void paintMinorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x)
protected void paintMajorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x)
protected void paintMinorTickForVertSlider(Graphics g, Rectangle tickBounds, int y)
protected void paintMajorTickForVertSlider(Graphics g, Rectangle tickBounds, int y)
public void paintLabels(Graphics g)
protected void paintHorizontalLabel(Graphics g, int value, Component label)
Called for every label in the label table. Used to draw the labels for horizontal sliders. The graphics have been translated to labelRect.y already.
protected void paintVerticalLabel(Graphics g, int value, Component label)
Called for every label in the label table. Used to draw the labels for vertical sliders. The graphics have been translated to labelRect.x already.
public void paintThumb(Graphics g)
public void setThumbLocation(int x, int y)
public void scrollByBlock(int direction)
public void scrollByUnit(int direction)
protected void scrollDueToClickInTrack(int dir)
This function is called when a mousePressed was detected in the track, not in the thumb. The default behavior is to scroll by block. You can override this method to stop it from scrolling or to add additional behavior.
protected int xPositionForValue(int value)
protected int yPositionForValue(int value)
protected int yPositionForValue(int value, int trackY, int trackHeight)
Returns the y location for the specified value. No checking is done on the arguments. In particular if trackHeight
is negative undefined results may occur.
value
- the slider value to get the location fortrackY
- y-origin of the tracktrackHeight
- the height of the trackpublic int valueForYPosition(int yPos)
Returns the value at the y position. If yPos
is beyond the track at the the bottom or the top, this method sets the value to either the minimum or maximum value of the slider, depending on if the slider is inverted or not.
public int valueForXPosition(int xPos)
Returns the value at the x position. If xPos
is beyond the track at the left or the right, this method sets the value to either the minimum or maximum value of the slider, depending on if the slider is inverted or not.
© 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.