public class Slider extends AbstractSlider
The size of a slider is dependent on the font size.
This example shows a simple slider:
Slider slider = new Slider(0, 100, 50);
This example shows a styled slider:
Slider slider = new Slider(0, 100, 50); EditableStyle sliderStyle = new EditableStyle(); sliderStyle.setForegroundColor(Colors.BLUE); sliderStyle.setBackgroundColor(Colors.SILVER); sliderStyle.setPadding(new SimpleOutline(1)); slider.mergeStyle(sliderStyle);
Modifier and Type | Field and Description |
---|---|
protected boolean |
horizontal
The orientation of the slider.
|
EMPTY_ELEMENT_ARRAY
Constructor and Description |
---|
Slider(BoundedRangeModel model)
Creates a horizontal slider with the given model.
|
Slider(int min,
int max,
int initialValue)
Creates a horizontal slider with a default bounded range model.
|
Modifier and Type | Method and Description |
---|---|
protected float |
computePercentComplete(int pointerX,
int pointerY)
Computes the percent complete according to the pointer coordinates.
|
void |
renderContent(GraphicsContext g,
Style style,
Rectangle bounds)
Renders the content of the renderable without the border, margin and padding specified in the style.
|
void |
setHorizontal(boolean horizontal)
Sets the slider orientation: horizontal or vertical.
|
Rectangle |
validateContent(Style style,
Rectangle availableSize)
Gets the content size of the renderable without the border, margin and padding specified in the style.
|
handleEvent
addOnValueChangeListener, getMaximum, getMinimum, getPercentComplete, getValue, removeOnValueChangeListener, reset, setMaximum, setMinimum, setModel, setValue
addClassSelector, contains, gainFocus, getAttribute, getChild, getChildrenCount, getChildrenElements, getContentBounds, getParentElement, getStyle, hasClassSelector, isInState, isTransparent, lostFocus, mergeStyle, removeAllClassSelectors, removeClassSelector, removeInstanceStyle, render, setClassSelectors, setEnabled, updateStyle, updateStyleOnly, validate
getAbsoluteX, getAbsoluteX, getAbsoluteY, getAbsoluteY, getEventHandler, getHeight, getPanel, getParent, getPreferredHeight, getPreferredWidth, getRelativeX, getRelativeY, getWidgetAt, getWidth, getX, getY, hasFocus, hideNotify, invalidate, isEnabled, isShown, isValid, isVisible, repaint, repaint, requestFocus, requestFocus, revalidate, revalidateSubTree, setBounds, setEventHandler, setLocation, setPreferredSize, setSize, setVisible, showNotify
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getEventHandler, getHeight, getWidth, getX, getY, hideNotify, isShown, repaint, repaint, setEventHandler, showNotify
public Slider(BoundedRangeModel model)
model
- the model to use.public Slider(int min, int max, int initialValue)
min
- the minimum value of the slider.max
- the maximum value of the slider.initialValue
- the initial value of the slider.DefaultBoundedRangeModel
public void setHorizontal(boolean horizontal)
horizontal
- true
to set the slider horizontal, false
to set the slider vertical.protected float computePercentComplete(int pointerX, int pointerY)
AbstractSlider
computePercentComplete
in class AbstractSlider
pointerX
- the x coordinate of the pointer.pointerY
- the y coordinate of the pointer.public void renderContent(GraphicsContext g, Style style, Rectangle bounds)
StyledRenderable
The given graphics context is translated and clipped according to the given bounds (the border, margin and padding are applied on this graphics context before).
g
- the graphics context where to render the content of the renderable.style
- the style to use.bounds
- the remaining size to render the content.Outline.apply(GraphicsContext, Rectangle)
,
Border.apply(GraphicsContext, Rectangle, int)
,
StyleHelper.renderWithoutContent(GraphicsContext, Rectangle, Style)
public Rectangle validateContent(Style style, Rectangle availableSize)
StyledRenderable
style
- the style to use.availableSize
- the bounds available for the content. A width or a height equals to MWT.NONE
means no
constraint on this dimension.