Java JTextField onTextFieldChange(JTextField field, final Runnable task)

Here you can find the source of onTextFieldChange(JTextField field, final Runnable task)

Description

on Text Field Change

License

Open Source License

Declaration

public static void onTextFieldChange(JTextField field, final Runnable task) 

Method Source Code

//package com.java2s;
/**/*from w w  w  . j  av  a  2s .  c o m*/
 * Copyright (C) 2010-14 pvmanager developers. See COPYRIGHT.TXT
 * All rights reserved. Use is subject to license terms. See LICENSE.TXT
 */

import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;

public class Main {
    public static void onTextFieldChange(JTextField field, final Runnable task) {
        field.getDocument().addDocumentListener(new DocumentListener() {

            @Override
            public void insertUpdate(DocumentEvent e) {
                task.run();
            }

            @Override
            public void removeUpdate(DocumentEvent e) {
                task.run();
            }

            @Override
            public void changedUpdate(DocumentEvent e) {
                task.run();
            }
        });
    }
}

Related

  1. isJTextFieldNotEmpty(javax.swing.JTextField field)
  2. isTelpValid(JTextField field)
  3. IsTextFieldEmpty(javax.swing.JTextField tf)
  4. isTextFieldModified(JTextField textField, String originalValue)
  5. newIntegerValue(JTextField text, int oldValue)
  6. parseTextFieldInteger(JTextField field)
  7. ponerMayuscula(KeyEvent e, JTextField textField)
  8. quickButtonFlip(JTextField t, JTextField a, JTextField b)
  9. readBufferedImage(JTextField out)