net.sourceforge.wohenchan
Class TimedDocumentReactor

java.lang.Object
  |
  +--net.sourceforge.wohenchan.TimedDocumentReactor
All Implemented Interfaces:
javax.swing.event.DocumentListener, java.util.EventListener

public class TimedDocumentReactor
extends java.lang.Object
implements javax.swing.event.DocumentListener

This class is a DocumentListener which aggregates calls to removeUpdate() and insertUpdate() and calls an ActionListener if enough time elapses without receiving any removeUpdate or insertUpdate calls. This is useful because it allows you to trigger an action off of someone typing into a field, without having the action happen every keystroke, and without forcing the user to press return or a button.

Version:
$Name: $ $Date: 2003/06/22 07:49:34 $
Author:
$Author: wtanaka $

Field Summary
(package private)  java.awt.event.ActionListener m_listener
           
(package private)  javax.swing.Timer m_timer
           
 
Constructor Summary
TimedDocumentReactor(int delay, java.awt.event.ActionListener listener)
           
 
Method Summary
 void changedUpdate(javax.swing.event.DocumentEvent evt)
           
 void insertUpdate(javax.swing.event.DocumentEvent evt)
           
 void removeUpdate(javax.swing.event.DocumentEvent evt)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_timer

javax.swing.Timer m_timer

m_listener

java.awt.event.ActionListener m_listener
Constructor Detail

TimedDocumentReactor

public TimedDocumentReactor(int delay,
                            java.awt.event.ActionListener listener)
Parameters:
delay - the number of milliseconds to wait after the last character is typed to react.
Method Detail

changedUpdate

public void changedUpdate(javax.swing.event.DocumentEvent evt)
Specified by:
changedUpdate in interface javax.swing.event.DocumentListener

removeUpdate

public void removeUpdate(javax.swing.event.DocumentEvent evt)
Specified by:
removeUpdate in interface javax.swing.event.DocumentListener

insertUpdate

public void insertUpdate(javax.swing.event.DocumentEvent evt)
Specified by:
insertUpdate in interface javax.swing.event.DocumentListener