com.vaadin.ui.
Class Slider
java.lang.Object
com.vaadin.ui.AbstractComponent
com.vaadin.ui.AbstractField
com.vaadin.ui.Slider
All Implemented Interfaces:
Buffered, BufferedValidatable, Property, Property.Editor, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer, Validatable, Action.ShortcutNotifier, MethodEventSource, Paintable, Sizeable, VariableOwner, Component, Component.Focusable, Field, Serializable, EventListener
- extends AbstractField
public class Slider
A component for selecting a numerical value within a range.
Example code:
class MyPlayer extends CustomComponent implements ValueChangeListener {
Label volumeIndicator = new Label();
Slider slider;
public MyPlayer() {
VerticalLayout vl = new VerticalLayout();
setCompositionRoot(vl);
slider = new Slider("Volume", 0, 100);
slider.setImmediate(true);
slider.setValue(new Double(50));
vl.addComponent(slider);
vl.addComponent(volumeIndicator);
volumeIndicator.setValue("Current volume:" + 50.0);
slider.addListener(this);
}
public void setVolume(double d) {
volumeIndicator.setValue("Current volume: " + d);
}
public void valueChange(ValueChangeEvent event) {
Double d = (Double) event.getProperty().getValue();
setVolume(d.doubleValue());
}
}
Author:
Vaadin Ltd.
See Also:
Nested Class Summary | |
---|---|
class |
Slider.ValueOutOfBoundsException
Thrown when the value of the slider is about to be set to a value that is outside the valid range of the slider. |
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractField |
---|
AbstractField.FocusShortcut, AbstractField.ReadOnlyStatusChangeEvent |
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractComponent |
---|
AbstractComponent.ComponentErrorEvent, AbstractComponent.ComponentErrorHandler |
Nested classes/interfaces inherited from interface com.vaadin.ui.Field |
---|
Field.ValueChangeEvent |
Nested classes/interfaces inherited from interface com.vaadin.data.Buffered |
---|
Buffered.SourceException |
Nested classes/interfaces inherited from interface com.vaadin.data.Property |
---|
Property.ConversionException, Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer |
Field Summary | |
---|---|
static int |
ORIENTATION_HORIZONTAL
|
static int |
ORIENTATION_VERTICAL
|
static String |
STYLE_SCROLLBAR
Deprecated. |
Constructor Summary | |
---|---|
Slider()
Default slider constructor. |
|
Slider(double min,
double max,
int resolution)
Create a new slider with the given range and resolution. |
|
Slider(int min,
int max)
Create a new slider with the given range that only allows integer values. |
|
Slider(String caption)
Create a new slider with the caption given as parameter. |
|
Slider(String caption,
int min,
int max)
Create a new slider with the given caption and range that only allows integer values. |
Method Summary | |
---|---|
void |
changeVariables(Object source,
Map<String,Object> variables)
Invoked when the value of a variable has changed. |
int |
getHandleSize()
Deprecated. The size is dictated by the current theme. |
double |
getMax()
Gets the maximum slider value |
double |
getMin()
Gets the minimum slider value |
int |
getOrientation()
Get the current orientation of the slider (horizontal or vertical). |
int |
getResolution()
Get the current resolution of the slider. |
int |
getSize()
Deprecated. use standard getWidth/getHeight instead |
Class |
getType()
Returns the type of the Property. |
void |
paintContent(PaintTarget target)
Paints any needed component-specific things to the given UIDL stream. |
void |
setHandleSize(int handleSize)
Deprecated. The size is dictated by the current theme. |
void |
setMax(double max)
Set the maximum slider value. |
void |
setMin(double min)
Set the minimum slider value. |
void |
setOrientation(int orientation)
Set the orientation of the slider. |
void |
setResolution(int resolution)
Set a new resolution for the slider. |
void |
setSize(int size)
Deprecated. use standard setWidth/setHeight instead |
void |
setValue(double value)
Sets the value of the slider. |
void |
setValue(Double value)
Sets the value of the slider. |
void |
setValue(Double value,
boolean repaintIsNotNeeded)
Sets the value of the slider. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.vaadin.ui.Field |
---|
getDescription, setCaption, setDescription |
Field Detail |
---|
ORIENTATION_HORIZONTAL
public static final int ORIENTATION_HORIZONTAL
See Also:
ORIENTATION_VERTICAL
public static final int ORIENTATION_VERTICAL
See Also:
STYLE_SCROLLBAR
@Deprecated
public static final String STYLE_SCROLLBAR
- See Also:
- Constant Field Values
Deprecated.
Style constant representing a scrollbar styled slider. Use this with
AbstractComponent.addStyleName(String)
. Default styling usually represents a
common slider found e.g. in Adobe Photoshop. The client side
implementation dictates how different styles will look.
Constructor Detail |
---|
Slider
public Slider()
Default slider constructor. Sets all values to defaults and the slide handle at minimum value.
Slider
public Slider(String caption)
- Parameters:
caption
- The caption for this slider (e.g. "Volume").
Create a new slider with the caption given as parameter. The range of the slider is set to 0-100 and only integer values are allowed.
Slider
public Slider(double min,
double max,
int resolution)
- Parameters:
min
- The minimum value of the slidermax
- The maximum value of the sliderresolution
- The number of digits after the decimal point.
Create a new slider with the given range and resolution.
Slider
public Slider(int min,
int max)
- Parameters:
min
- The minimum value of the slidermax
- The maximum value of the slider
Create a new slider with the given range that only allows integer values.
Slider
public Slider(String caption,
int min,
int max)
- Parameters:
caption
- The caption for the slidermin
- The minimum value of the slidermax
- The maximum value of the slider
Create a new slider with the given caption and range that only allows integer values.
Method Detail |
---|
getMax
public double getMax()
- Returns:
- the largest value the slider can have
Gets the maximum slider value
setMax
public void setMax(double max)
- Parameters:
max
- The new maximum slider value
Set the maximum slider value. If the current value of the slider is larger than this, the value is set to the new maximum.
getMin
public double getMin()
- Returns:
- the smallest value the slider can have
Gets the minimum slider value
setMin
public void setMin(double min)
- Parameters:
max
- The new minimum slider value
Set the minimum slider value. If the current value of the slider is smaller than this, the value is set to the new minimum.
getOrientation
public int getOrientation()
- Returns:
ORIENTATION_HORIZONTAL
orORIENTATION_HORIZONTAL
Get the current orientation of the slider (horizontal or vertical).
setOrientation
public void setOrientation(int orientation)
- Parameters:
The
- new orientation, eitherORIENTATION_HORIZONTAL
orORIENTATION_VERTICAL
Set the orientation of the slider.
getResolution
public int getResolution()
- Returns:
- resolution
Get the current resolution of the slider. The resolution is the number of digits after the decimal point.
setResolution
public void setResolution(int resolution)
- Parameters:
resolution
-
Set a new resolution for the slider. The resolution is the number of digits after the decimal point.
setValue
public void setValue(Double value,
boolean repaintIsNotNeeded)
throws Slider.ValueOutOfBoundsException
- Parameters:
value
- The new value of the slider.repaintIsNotNeeded
- If true, client-side is not requested to repaint itself.- Throws:
Slider.ValueOutOfBoundsException
- If the given value is not inside the range of the slider.- See Also:
{@link #setMax(double)}
Sets the value of the slider.
setValue
public void setValue(Double value)
throws Slider.ValueOutOfBoundsException
- Parameters:
value
- The new value of the slider.- Throws:
Slider.ValueOutOfBoundsException
- If the given value is not inside the range of the slider.- See Also:
{@link #setMax(double)}
Sets the value of the slider.
setValue
public void setValue(double value)
throws Slider.ValueOutOfBoundsException
- Parameters:
value
- The new value of the slider.- Throws:
Slider.ValueOutOfBoundsException
- If the given value is not inside the range of the slider.- See Also:
{@link #setMax(double)}
Sets the value of the slider.
getSize
@Deprecated
public int getSize()
- Returns:
- size in pixels or -1 for auto sizing.
Deprecated. use standard getWidth/getHeight instead
Get the current slider size.
setSize
@Deprecated
public void setSize(int size)
- Parameters:
size
- in pixels, or -1 auto sizing.
Deprecated. use standard setWidth/setHeight instead
Set the size for this slider.
getHandleSize
@Deprecated
public int getHandleSize()
- Returns:
- handle size in percentages.
Deprecated. The size is dictated by the current theme.
Get the handle size of this slider.
setHandleSize
@Deprecated
public void setHandleSize(int handleSize)
- Parameters:
handleSize
- in percentages relative to slider base size.
Deprecated. The size is dictated by the current theme.
Set the handle size of this slider.
paintContent
public void paintContent(PaintTarget target)
throws PaintException
- Overrides:
paintContent
in classAbstractField
- Parameters:
target
- the target UIDL stream where the component should paint itself to- Throws:
PaintException
- if the paint operation failed.
Description copied from class: AbstractComponent
Paints any needed component-specific things to the given UIDL stream. The
more general AbstractComponent.paint(PaintTarget)
method handles all general
attributes common to all components, and it calls this method to paint
any component-specific attributes to the UIDL stream.
changeVariables
public void changeVariables(Object source,
Map<String,Object> variables)
- Specified by:
changeVariables
in interfaceVariableOwner
- Overrides:
changeVariables
in classAbstractField
- Parameters:
source
-variables
-
Invoked when the value of a variable has changed. Slider listeners are notified if the slider value has changed.
getType
public Class getType()
- Specified by:
getType
in interfaceProperty
- Specified by:
getType
in classAbstractField
- Returns:
- type of the Property
Description copied from interface: Property
Returns the type of the Property. The methods getValue
and
setValue
must be compatible with this type: one must be able
to safely cast the value returned from getValue
to the given
type and pass any variable assignable to this type as an argument to
setValue
.