com.vaadin.ui
Class Slider

java.lang.Object
  extended by com.vaadin.terminal.AbstractClientConnector
      extended by com.vaadin.ui.AbstractComponent
          extended by com.vaadin.ui.AbstractField<Double>
              extended by com.vaadin.ui.Slider
All Implemented Interfaces:
Buffered, BufferedValidatable, Property<Double>, Property.Editor, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer, Validatable, Action.ShortcutNotifier, MethodEventSource, Connector, ClientConnector, RpcTarget, Sizeable, Vaadin6Component, VariableOwner, Component, Component.Focusable, Field<Double>, Serializable, EventListener

public class Slider
extends AbstractField<Double>
implements Vaadin6Component

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:
Serialized Form

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.terminal.VariableOwner
VariableOwner.ErrorEvent
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.ErrorListener, Component.Event, Component.Focusable, Component.Listener
 
Nested classes/interfaces inherited from interface com.vaadin.terminal.Sizeable
Sizeable.Unit
 
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.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.Transactional<T>, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer
 
Field Summary
static int ORIENTATION_HORIZONTAL
           
static int ORIENTATION_VERTICAL
           
 
Fields inherited from interface com.vaadin.terminal.Sizeable
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
 
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.
 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.
 Class<Double> getType()
          Returns the type of the Field.
 void paintContent(PaintTarget target)
           Paints the Paintable into a UIDL stream.
 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.
protected  void setValue(Double value, boolean repaintIsNotNeeded)
          Sets the value of the slider.
 void setValue(Object newFieldValue)
          Sets the value of the field.
 
Methods inherited from class com.vaadin.ui.AbstractField
addListener, addListener, addValidator, attach, commit, detach, discard, fireReadOnlyStatusChange, fireValueChange, focus, getConversionError, getConversionError, getConvertedValue, getConverter, getCurrentBufferedSourceException, getErrorMessage, getInternalValue, getPropertyDataSource, getRequiredError, getState, getTabIndex, getValidators, getValue, isBuffered, isEmpty, isInvalidAllowed, isInvalidCommitted, isModified, isReadOnly, isReadThrough, isRequired, isValid, isValidationVisible, isWriteThrough, readOnlyStatusChange, removeAllValidators, removeListener, removeListener, removeValidator, setBuffered, setConversionError, setConvertedValue, setConverter, setConverter, setCurrentBufferedSourceException, setInternalValue, setInvalidAllowed, setInvalidCommitted, setPropertyDataSource, setReadOnly, setReadThrough, setRequired, setRequiredError, setTabIndex, setValidationVisible, setWriteThrough, shouldHideErrors, toString, updateState, validate, validate, valueChange
 
Methods inherited from class com.vaadin.ui.AbstractComponent
addListener, addListener, addListener, addListener, addShortcutListener, addStyleName, findAncestor, fireComponentErrorEvent, fireComponentEvent, fireEvent, getActionManager, getApplication, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorHandler, getHeight, getHeightUnits, getIcon, getListeners, getLocale, getParent, getRoot, getStyle, getStyleName, getWidth, getWidthUnits, handleError, hasListeners, isConnectorEnabled, isEnabled, isImmediate, isVisible, removeListener, removeListener, removeListener, removeListener, removeListener, removeShortcutListener, removeStyleName, requestRepaint, setCaption, setComponentError, setData, setDebugId, setDescription, setEnabled, setErrorHandler, setHeight, setHeight, setIcon, setImmediate, setLocale, setParent, setSizeFull, setSizeUndefined, setStyle, setStyleName, setVisible, setWidth, setWidth
 
Methods inherited from class com.vaadin.terminal.AbstractClientConnector
addExtension, addMethodInvocationToQueue, createState, getAllChildrenIterable, getConnectorId, getExtensions, getRpcManager, getRpcProxy, getStateType, registerRpc, registerRpc, removeExtension, requestRepaintAll, retrievePendingRpcCalls
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.vaadin.terminal.VariableOwner
isEnabled, isImmediate
 
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, attach, getApplication, getCaption, getDebugId, getIcon, getLocale, getParent, getRoot, getState, getStyleName, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setCaption, setDebugId, setEnabled, setIcon, setReadOnly, setStyleName, setVisible, updateState
 
Methods inherited from interface com.vaadin.terminal.gwt.server.ClientConnector
detach, getExtensions, getStateType, isConnectorEnabled, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setParent
 
Methods inherited from interface com.vaadin.terminal.gwt.client.Connector
getConnectorId
 
Methods inherited from interface com.vaadin.terminal.gwt.server.RpcTarget
getRpcManager
 
Methods inherited from interface com.vaadin.terminal.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setSizeFull, setSizeUndefined, setWidth, setWidth
 
Methods inherited from interface com.vaadin.event.Action.ShortcutNotifier
addShortcutListener, removeShortcutListener
 

Field Detail

ORIENTATION_HORIZONTAL

public static final int ORIENTATION_HORIZONTAL
See Also:
Constant Field Values

ORIENTATION_VERTICAL

public static final int ORIENTATION_VERTICAL
See Also:
Constant Field Values
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)
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.

Parameters:
caption - The caption for this slider (e.g. "Volume").

Slider

public Slider(double min,
              double max,
              int resolution)
Create a new slider with the given range and resolution.

Parameters:
min - The minimum value of the slider
max - The maximum value of the slider
resolution - The number of digits after the decimal point.

Slider

public Slider(int min,
              int max)
Create a new slider with the given range that only allows integer values.

Parameters:
min - The minimum value of the slider
max - The maximum value of the slider

Slider

public Slider(String caption,
              int min,
              int max)
Create a new slider with the given caption and range that only allows integer values.

Parameters:
caption - The caption for the slider
min - The minimum value of the slider
max - The maximum value of the slider
Method Detail

getMax

public double getMax()
Gets the maximum slider value

Returns:
the largest value the slider can have

setMax

public void setMax(double max)
Set the maximum slider value. If the current value of the slider is larger than this, the value is set to the new maximum.

Parameters:
max - The new maximum slider value

getMin

public double getMin()
Gets the minimum slider value

Returns:
the smallest value the slider can have

setMin

public void setMin(double min)
Set the minimum slider value. If the current value of the slider is smaller than this, the value is set to the new minimum.

Parameters:
max - The new minimum slider value

getOrientation

public int getOrientation()
Get the current orientation of the slider (horizontal or vertical).

Returns:
ORIENTATION_HORIZONTAL or ORIENTATION_HORIZONTAL

setOrientation

public void setOrientation(int orientation)
Set the orientation of the slider.

Parameters:
The - new orientation, either ORIENTATION_HORIZONTAL or ORIENTATION_VERTICAL

getResolution

public int getResolution()
Get the current resolution of the slider. The resolution is the number of digits after the decimal point.

Returns:
resolution

setResolution

public void setResolution(int resolution)
Set a new resolution for the slider. The resolution is the number of digits after the decimal point.

Parameters:
resolution -

setValue

protected void setValue(Double value,
                        boolean repaintIsNotNeeded)
Sets the value of the slider.

Overrides:
setValue in class AbstractField<Double>
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)}

setValue

public void setValue(Object newFieldValue)
              throws Property.ReadOnlyException
Description copied from class: AbstractField
Sets the value of the field.

Specified by:
setValue in interface Property<Double>
Overrides:
setValue in class AbstractField<Double>
Parameters:
newFieldValue - the New value of the field.
Throws:
Property.ReadOnlyException - if the object is in read-only mode

paintContent

public void paintContent(PaintTarget target)
                  throws PaintException
Description copied from interface: Vaadin6Component

Paints the Paintable into a UIDL stream. This method creates the UIDL sequence describing it and outputs it to the given UIDL stream.

It is called when the contents of the component should be painted in response to the component first being shown or having been altered so that its visual representation is changed.

Specified by:
paintContent in interface Vaadin6Component
Parameters:
target - the target UIDL stream where the component should paint itself to.
Throws:
PaintException - if the paint operation failed.

changeVariables

public void changeVariables(Object source,
                            Map<String,Object> variables)
Invoked when the value of a variable has changed. Slider listeners are notified if the slider value has changed.

Specified by:
changeVariables in interface VariableOwner
Parameters:
source -
variables -

getType

public Class<Double> getType()
Description copied from class: AbstractField
Returns the type of the Field. 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.

Specified by:
getType in interface Property<Double>
Specified by:
getType in class AbstractField<Double>
Returns:
the type of the Field


Copyright © 2000-2011 Vaadin Ltd. All Rights Reserved.