Java JTextField addInputValidator(final DocumentListener inputValidator, final JTextField... textFields)

Here you can find the source of addInputValidator(final DocumentListener inputValidator, final JTextField... textFields)

Description

Adds input validator to text fields.

License

Open Source License

Parameter

Parameter Description
inputValidator input validator
textFields text fields

Declaration

public static void addInputValidator(final DocumentListener inputValidator, final JTextField... textFields) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.*;
import javax.swing.event.DocumentListener;

public class Main {
    /**//from  www.j  a  v  a2s .c o  m
     * Adds input validator to text fields.
     *
     * @param inputValidator input validator
     * @param textFields     text fields
     */
    public static void addInputValidator(final DocumentListener inputValidator, final JTextField... textFields) {
        for (final JTextField textField : textFields) {
            textField.getDocument().addDocumentListener(inputValidator);
        }
    }
}

Related

  1. addHighlight(JTextField label, MouseEvent mouseEvent1, MouseEvent mouseEvent2)
  2. addLabelTextRows(JLabel[] labels, JTextField[] textFields, GridBagLayout gridbag, Container container)
  3. addPlaceHolder(final JTextField field, final String placeHolderText)
  4. addStyle(JTextField textField, String labelName)
  5. adjustTextToRight(JTextField textField)