Module org.jpo

Class WholeNumberField

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

public class WholeNumberField extends JTextField
This class extends the JTextField and allow only entry of digits. This was the suggested method in the Swing tutorials in February 2002 when I wrote this class. Java probably didn't have NumberFormatter, FormattedTextFields etc. in those days.
See Also:
  • Constructor Details

    • WholeNumberField

      public WholeNumberField()
    • WholeNumberField

      public WholeNumberField(int defaultValue, int width)
      Constructor.
      Parameters:
      defaultValue - The initial value of the field
      width - The width of the field in number of characters
  • Method Details

    • getValue

      public int getValue()
      method that returns the value of the WholeNumberField
      Returns:
      the value of the field
    • getValueAsDouble

      public double getValueAsDouble()
      method that returns the value of the WholeNumberField
      Returns:
      the value of the field
    • setValue

      public void setValue(int value)
      method that sets the value of the WholeNumberField
      Parameters:
      value - value
    • setValue

      public void setValue(double value)
      method that sets the value of the WholeNumberField
      Parameters:
      value - value
    • createDefaultModel

      protected Document createDefaultModel()
      part of the inner workings
      Overrides:
      createDefaultModel in class JTextField
      Returns:
      the document