Class NumberField

java.lang.Object
ca.corbett.forms.fields.FormField
ca.corbett.forms.fields.NumberField

public final class NumberField extends FormField
A FormField that wraps a JSpinner to allow numeric input. The underlying JSpinner is accessible by invoking getFieldComponent() and casting the result to JSpinner.
Since:
2020-09-25
Author:
scorbo2
  • Constructor Details

    • NumberField

      public NumberField(String labelText, int initialValue, int minimum, int maximum, int step)
      Creates an integer-based NumberField using the given starting values.
      Parameters:
      labelText - The label to show for the field.
      initialValue - The starting value.
      minimum - The minimum value.
      maximum - The maximum value.
      step - The increment value.
    • NumberField

      public NumberField(String labelText, double initialValue, double minimum, double maximum, double step)
      Creates a floating point NumberField using the given starting values.
      Parameters:
      labelText - The label to show for the field.
      initialValue - The starting value.
      minimum - The minimum value.
      maximum - The maximum value.
      step - The increment value.
    • NumberField

      public NumberField(String labelText, SpinnerModel model)
      Creates a NumberField using the given SpinnerModel. Normally you can use the other constructors in this class as a convenience to avoid having to create the SpinnerModel yourself, but this constructor is useful if you want to be able to change the parameters of the spinner dynamically, for example to change the increment or to set a new min or max value.
      Parameters:
      labelText - The label to show for the field.
      model - A SpinnerModel instance containing our spinner parameters.
  • Method Details

    • getCurrentValue

      public Number getCurrentValue()
    • setCurrentValue

      public NumberField setCurrentValue(Number value)