Class RangeSlider

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, SwingConstants

public class RangeSlider extends JSlider
RangeSlider is a slider that can be used to select a range. A regular slider has only one thumb. So it can only be used to select one value. RangeSlider has two thumbs. Each one can be moved independently or both are moved together.

getLowValue() will return the value of low range and getHighValue() is the high range.

See Also:
  • Field Details

  • Constructor Details

    • RangeSlider

      public RangeSlider()
      Creates a horizontal range slider with the range 0 to 100 and initial low and high values both at 50.
    • RangeSlider

      public RangeSlider(int orientation)
      Creates a range slider using the specified orientation with the range 0 to 100 and initial low and high values both at 50.
      Parameters:
      orientation - the orientation of the RangeSlider.
    • RangeSlider

      public RangeSlider(int min, int max)
      Creates a horizontal slider using the specified min and max with an initial value equal to the average of the min plus max. and initial low and high values both at 50.
      Parameters:
      min - the minimum value of the slider.
      max - the maximum value of the slider.
    • RangeSlider

      public RangeSlider(int min, int max, int low, int high)
      Creates a horizontal slider using the specified min, max, low and high value.
      Parameters:
      min - the minimum value of the slider.
      max - the maximum value of the slider.
      low - the low value of the slider since it is a range.
      high - the high value of the slider since it is a range.
  • Method Details

    • getActualUIClassID

      public String getActualUIClassID()
    • updateUI

      public void updateUI()
      Overrides:
      updateUI in class JSlider
    • getLowValue

      public int getLowValue()
      Returns the range slider's low value.
      Returns:
      the range slider's low value.
    • getHighValue

      public int getHighValue()
      Returns the range slider's high value.
      Returns:
      the range slider's high value.
    • contains

      public boolean contains(int value)
      Returns true if the specified value is within the range slider's range.
      Parameters:
      value - value
      Returns:
      true if the specified value is within the range slider's range.
    • setValue

      public void setValue(int value)
      Overrides:
      setValue in class JSlider
    • setLowValue

      public void setLowValue(int lowValue)
      Sets the range slider's low value. This method just forwards the value to the model.
      Parameters:
      lowValue - the new low value
    • setHighValue

      public void setHighValue(int highValue)
      Sets the range slider's high value. This method just forwards the value to the model.
      Parameters:
      highValue - the new high value
    • isRangeDraggable

      public boolean isRangeDraggable()
      Checks if the range is draggable. If true, user can drag the area between the two thumbs to drag the range.
      Returns:
      true or false.
    • setRangeDraggable

      public void setRangeDraggable(boolean rangeDraggable)
      Sets the flag if the range is draggable. If true, user can drag the area between the two thumbs to drag the range.
      Parameters:
      rangeDraggable - true or false.