Class DoubleSpinner

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class DoubleSpinner extends JSpinner
A single line input field that lets the user show and select real number from an ordered sequence. Mapping of real values into the corresponding integer scale is available as well.
See Also:
  • Constructor Details

    • DoubleSpinner

      public DoubleSpinner(double val, double min, double max, int fractionDigits)
      Constructor.
      Parameters:
      val - Initial value
      min - Minimum allowed value
      max - Maximum allowed value
      fractionDigits - precision of floating numbers, i.e., the number of digits allowed after the floating dot. Must be bigger than zero.
  • Method Details

    • getDoubleMinimum

      public double getDoubleMinimum()
      Returns the minimum allowed value as a real number.
      Returns:
      the minimum allowed value
    • getDoubleMaximum

      public double getDoubleMaximum()
      Returns the maximum allowed value as a real number.
      Returns:
      the maximum allowed value
    • getDoubleValue

      public double getDoubleValue()
      Returns current value as a real number.
      Returns:
      current value
    • getIntegerMinimum

      public int getIntegerMinimum()
      Returns the minimum allowed value as an integer (the real value multiplied by the getFractionDecimals().
      Returns:
      the minimum allowed value
    • getIntegerMaximum

      public int getIntegerMaximum()
      Returns the maximum allowed value as an integer (the real value multiplied by the getFractionDecimals().
      Returns:
      the maximum allowed value
    • getIntegerValue

      public int getIntegerValue()
      Returns current value as an integer (the real value multiplied by the getFractionDecimals().
      Returns:
      current value
    • setValue

      public void setValue(Object value)
      This method sets the double value, but round it into the number of decimal digits given by fractionDigits parameter provided to the constructor.
      Overrides:
      setValue in class JSpinner
      Parameters:
      value - double value to be set
      Throws:
      IllegalArgumentException - if value isn't allowed
    • convertValue

      public double convertValue(Object value)
      This method converts the given value by rounding it into the number of decimal digits given by fractionDigits parameter provided to the constructor.
      Parameters:
      value - double value to be set
      Throws:
      IllegalArgumentException - if value isn't allowed
    • getFractionDecimals

      public int getFractionDecimals()
      Returns 1, 10, etc., based on the number of fraction digits 1, 2, ...
      Returns:
      1, 10, etc., based on the number of fraction digits 1, 2, ...