Class AbstractTextComponentValidator

    • Constructor Detail

      • AbstractTextComponentValidator

        protected AbstractTextComponentValidator​(javax.swing.text.JTextComponent tc)
        Creates the validator and wires it to the text component tc.
        Parameters:
        tc - the text component. Must not be null.
        Throws:
        java.lang.IllegalArgumentException - if tc is null
      • AbstractTextComponentValidator

        protected AbstractTextComponentValidator​(javax.swing.text.JTextComponent tc,
                                                 boolean addActionListener)
        Alternative constructor that allows to turn off the actionListener. This can be useful if the enter key stroke needs to be forwarded to the default button in a dialog.
        Parameters:
        tc - text component
        addActionListener - true to add the action listener
      • AbstractTextComponentValidator

        protected AbstractTextComponentValidator​(javax.swing.text.JTextComponent tc,
                                                 boolean addFocusListener,
                                                 boolean addDocumentListener,
                                                 boolean addActionListener)
        Constructs a new AbstractTextComponentValidator.
        Parameters:
        tc - text component
        addFocusListener - true to add the focus listener
        addDocumentListener - true to add the document listener
        addActionListener - true to add the action listener
    • Method Detail

      • feedbackInvalid

        protected void feedbackInvalid​(java.lang.String msg)
      • feedbackWarning

        protected void feedbackWarning​(java.lang.String msg)
      • feedbackValid

        protected void feedbackValid​(java.lang.String msg)
      • getComponent

        public javax.swing.text.JTextComponent getComponent()
        Replies the decorated text component
        Returns:
        the decorated text component
      • validate

        public abstract void validate()
        Implement in subclasses to validate the content of the text component.
      • isValid

        public abstract boolean isValid()
        Replies true if the current content of the decorated text component is valid; false otherwise
        Returns:
        true if the current content of the decorated text component is valid
      • focusGained

        public void focusGained​(java.awt.event.FocusEvent e)
        Specified by:
        focusGained in interface java.awt.event.FocusListener
      • focusLost

        public void focusLost​(java.awt.event.FocusEvent e)
        Specified by:
        focusLost in interface java.awt.event.FocusListener
      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent e)
        Specified by:
        actionPerformed in interface java.awt.event.ActionListener
      • changedUpdate

        public void changedUpdate​(javax.swing.event.DocumentEvent e)
        Specified by:
        changedUpdate in interface javax.swing.event.DocumentListener
      • insertUpdate

        public void insertUpdate​(javax.swing.event.DocumentEvent e)
        Specified by:
        insertUpdate in interface javax.swing.event.DocumentListener
      • removeUpdate

        public void removeUpdate​(javax.swing.event.DocumentEvent e)
        Specified by:
        removeUpdate in interface javax.swing.event.DocumentListener
      • propertyChange

        public void propertyChange​(java.beans.PropertyChangeEvent evt)
        Specified by:
        propertyChange in interface java.beans.PropertyChangeListener