Here you can find the source of textAreaChangeListener(JTextField a, final ChangeListener list)
public static void textAreaChangeListener(JTextField a, final ChangeListener list)
//package com.java2s; /***/*from ww w . j a va 2 s.c o m*/ * Copyright (C) 2010 Johan Henriksson * This code is under the Endrov / BSD license. See www.endrov.net * for the full text and how to cite. */ import javax.swing.*; import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; public class Main { /** * Reroute all document changes to a change listener */ public static void textAreaChangeListener(JTextArea a, final ChangeListener list) { a.getDocument().addDocumentListener(new DocumentListener() { public void change() { list.stateChanged(null); } public void changedUpdate(DocumentEvent e) { change(); } public void removeUpdate(DocumentEvent e) { change(); } public void insertUpdate(DocumentEvent e) { change(); } }); } /** * Reroute all document changes to a change listener */ public static void textAreaChangeListener(JTextField a, final ChangeListener list) { a.getDocument().addDocumentListener(new DocumentListener() { public void change() { list.stateChanged(null); } public void changedUpdate(DocumentEvent e) { change(); } public void removeUpdate(DocumentEvent e) { change(); } public void insertUpdate(DocumentEvent e) { change(); } }); } }