Class IntegerInputVerifier


  • public class IntegerInputVerifier
    extends javax.swing.InputVerifier
    Verifies whether text input via a JTextField is an integer that falls within a specified set of bounds.
    • Constructor Summary

      Constructors 
      Constructor Description
      IntegerInputVerifier​(int min, int max, java.awt.Color background, java.awt.Color warningBackground)
      Initialize the input verifier with an integer range and background colors.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getMax()  
      int getMin()  
      boolean shouldYieldFocus​(javax.swing.JComponent input)
      Verifies the input with the side effect that the background color of input to background if returns true, or warningBackground otherwise
      boolean verify​(javax.swing.JComponent input)
      Verifies that the input's text value can be converted to an integer that is >= min and <=max.
      • Methods inherited from class javax.swing.InputVerifier

        shouldYieldFocus, verifyTarget
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • IntegerInputVerifier

        public IntegerInputVerifier​(int min,
                                    int max,
                                    java.awt.Color background,
                                    java.awt.Color warningBackground)
        Initialize the input verifier with an integer range and background colors.
        Parameters:
        min - the minimum permissible integer value
        max - the maximum permissible integer value
        background - the background color to set on the JComponent if the input is valid
        warningBackground - the background color to set on the JComponent if the input is invalid
    • Method Detail

      • getMin

        public int getMin()
      • getMax

        public int getMax()
      • shouldYieldFocus

        public boolean shouldYieldFocus​(javax.swing.JComponent input)
        Verifies the input with the side effect that the background color of input to background if returns true, or warningBackground otherwise
        Overrides:
        shouldYieldFocus in class javax.swing.InputVerifier
        Parameters:
        input - component
        Returns:
        if input is valid
      • verify

        public boolean verify​(javax.swing.JComponent input)
        Verifies that the input's text value can be converted to an integer that is >= min and <=max.
        Specified by:
        verify in class javax.swing.InputVerifier
        Parameters:
        input - a JTextField instance
        Returns:
        true if an only if the text input contains a value that