Package swingtree

Class UIForSlider<S extends JSlider>


public final class UIForSlider<S extends JSlider> extends UIForAnySwing<UIForSlider<S>,S>
A SwingTree builder node designed for configuring JSlider instances.

Please take a look at the living swing-tree documentation where you can browse a large collection of examples demonstrating how to use the API of this class.

  • Method Details

    • _state

      protected swingtree.BuilderState<S> _state()
      Description copied from class: UIForAnything
      Returns the state of the builder, which is a container for the wrapped component as well as it's type and current EventProcessor.
      Specified by:
      _state in class UIForAnything<UIForSlider<S extends JSlider>,S extends JSlider,JComponent>
      Returns:
      The state of the builder.
    • _newBuilderWithState

      protected UIForSlider<S> _newBuilderWithState(swingtree.BuilderState<S> newState)
      Description copied from class: UIForAnything
      An internal wither method which creates a new builder instance with the provided BuilderState stored inside it.
      Specified by:
      _newBuilderWithState in class UIForAnything<UIForSlider<S extends JSlider>,S extends JSlider,JComponent>
      Parameters:
      newState - The new state which should be stored inside the new builder instance.
      Returns:
      A new builder instance with the provided state stored inside it.
    • withOrientation

      public final UIForSlider<S> withOrientation(UI.Align align)
      Sets the orientation of the slider.
      Parameters:
      align - The orientation of the slider.
      Returns:
      This builder node.
    • withOrientation

      public final UIForSlider<S> withOrientation(sprouts.Val<UI.Align> align)
      Dynamically sets the orientation of the slider.
      Parameters:
      align - The orientation of the slider.
      Returns:
      This builder node.
    • onChange

      public final UIForSlider<S> onChange(sprouts.Action<ComponentDelegate<JSlider,ChangeEvent>> action)
      Adds an Action to the underlying JSlider through an ChangeListener, which will be called when the state of the slider changes. For more information see JSlider.addChangeListener(javax.swing.event.ChangeListener).
      Parameters:
      action - The Action that will be called through the underlying change event.
      Returns:
      This very instance, which enables builder-style method chaining.
      Throws:
      IllegalArgumentException - if action is null.
    • withMin

      public final UIForSlider<S> withMin(int min)
      Sets the minimum value of the slider. For more information see JSlider.setMinimum(int).
      Parameters:
      min - The minimum value of the slider.
      Returns:
      This very instance, which enables builder-style method chaining.
    • withMin

      public final UIForSlider<S> withMin(sprouts.Val<Integer> min)
      Binds the supplied Val property to the min value of the slider so that when the value of the property changes, the min value of the slider will be updated accordingly. For more information about the underlying value in the component, see JSlider.setMinimum(int).
      Parameters:
      min - The min property used to dynamically update the min value of the slider.
      Returns:
      This very instance, which enables builder-style method chaining.
      Throws:
      IllegalArgumentException - if min is null.
    • withMax

      public final UIForSlider<S> withMax(int max)
      Sets the maximum value of the slider. For more information see JSlider.setMaximum(int) (int)}.
      Parameters:
      max - The maximum value of the slider.
      Returns:
      This very instance, which enables builder-style method chaining.
    • withMax

      public final UIForSlider<S> withMax(sprouts.Val<Integer> max)
      Binds the supplied Val property to the max value of the slider. When the value of the property changes, the max value of the slider will be updated accordingly. For more information about the underlying value in the component, see JSlider.setMaximum(int).
      Parameters:
      max - An integer property used to dynamically update the max value of the slider.
      Returns:
      This very instance, which enables builder-style method chaining.
      Throws:
      IllegalArgumentException - if max is null.
    • withValue

      public final UIForSlider<S> withValue(int value)
      Sets the current value of the slider. For more information see JSlider.setValue(int).
      Parameters:
      value - The current value of the slider.
      Returns:
      This very instance, which enables builder-style method chaining.
    • withValue

      public final UIForSlider<S> withValue(sprouts.Val<Integer> val)
      Binds the supplied Val property to the value of the slider, which causes the knob of the slider to move when the value of the property changes. But note that the supplied property is a read only, so when the user updates the value of the slider, the property will not be updated. Use withValue(Var) if you want to bind a property bidirectionally. For more information about the underlying value in the component, see JSlider.setValue(int).
      Parameters:
      val - An integer property used to dynamically update the value of the slider.
      Returns:
      This very instance, which enables builder-style method chaining.
      Throws:
      IllegalArgumentException - if value is null.
    • withValue

      public final UIForSlider<S> withValue(sprouts.Var<Integer> var)
      Use this to bind the supplied Var property to the value of the slider. When the value of the slider changes, the value of the Var will be updated and when the item of the Var is changed as part of the application logic, the value of the slider will be updated accordingly.
      Parameters:
      var - An integer property used to dynamically update the value of the slider.
      Returns:
      This very instance, which enables builder-style method chaining.
      Throws:
      IllegalArgumentException - if value is null.
    • withMajorTickSpacing

      public final UIForSlider<S> withMajorTickSpacing(int spacing)
      Sets the major tick spacing of the slider. For more information see JSlider.setMajorTickSpacing(int).
      Parameters:
      spacing - The major tick spacing of the slider.
      Returns:
      This very instance, which enables builder-style method chaining.
    • withMinorTickSpacing

      public final UIForSlider<S> withMinorTickSpacing(int spacing)
      Sets the minor tick spacing of the slider. For more information see JSlider.setMinorTickSpacing(int).
      Parameters:
      spacing - The minor tick spacing of the slider.
      Returns:
      This very instance, which enables builder-style method chaining.
    • withMajorTickSpacing

      public final UIForSlider<S> withMajorTickSpacing(sprouts.Val<Integer> spacing)
      Dynamically sets the major tick spacing of the slider. For more information see JSlider.setMajorTickSpacing(int).
      Parameters:
      spacing - The major tick spacing of the slider.
      Returns:
      This very instance, which enables builder-style method chaining.
      Throws:
      IllegalArgumentException - if spacing is null.
    • withMinorTickSpacing

      public final UIForSlider<S> withMinorTickSpacing(sprouts.Val<Integer> spacing)
      Dynamically sets the minor tick spacing of the slider. For more information see JSlider.setMinorTickSpacing(int).
      Parameters:
      spacing - The minor tick spacing of the slider.
      Returns:
      This very instance, which enables builder-style method chaining.
      Throws:
      IllegalArgumentException - if spacing is null.