|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.wotonomy.ui.swing.components.KeyDelayTimer
public class KeyDelayTimer
KeyDelayTimer is a utility that listens for KeyEvents from one
or more components. After receiving a KeyEvents the timer will
broadcast an action event if a specified time interval passes without
a subsequent KeyEvent.
This utility is useful for implementing any kind of auto-complete
feature in a user interface.
Field Summary | |
---|---|
protected java.awt.event.ActionListener |
actionListener
|
protected int |
interval
|
protected javax.swing.Timer |
keyTimer
|
protected java.awt.Component |
lastFieldTouched
|
protected long |
timeLastFieldTouched
|
Constructor Summary | |
---|---|
KeyDelayTimer()
Default constructor. |
|
KeyDelayTimer(java.awt.event.ActionListener listener)
Convenience constructor. |
Method Summary | |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent e)
Receives ActionEvents from the internal timer. |
void |
addActionListener(java.awt.event.ActionListener l)
Adds an action listener to the list that will be notified by button events and changes in button state. |
protected void |
broadcastEvent(java.awt.event.ActionEvent e)
Notifies all registered action listeners of a pending Action Event. |
java.awt.Component |
getComponent()
Returns the last component that generated a KeyEvent. |
int |
getInterval()
Returns the number of milliseconds before an ActionEvent is generated. |
void |
keyPressed(java.awt.event.KeyEvent e)
|
void |
keyReleased(java.awt.event.KeyEvent e)
Receives key events from one or more components. |
void |
keyTyped(java.awt.event.KeyEvent e)
|
void |
removeActionListener(java.awt.event.ActionListener l)
Removes an action listener from the list that will be notified by button events and changes in button state. |
void |
setInterval(int millis)
Sets the number of milliseconds before an ActionEvent will be generated after a KeyEvent is received. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected javax.swing.Timer keyTimer
protected java.awt.Component lastFieldTouched
protected long timeLastFieldTouched
protected int interval
protected java.awt.event.ActionListener actionListener
Constructor Detail |
---|
public KeyDelayTimer()
public KeyDelayTimer(java.awt.event.ActionListener listener)
listener
- An action listener to be notified of delay events.Method Detail |
---|
public java.awt.Component getComponent()
public int getInterval()
public void setInterval(int millis)
millis
- The new delay interval in milliseconds.public void keyTyped(java.awt.event.KeyEvent e)
keyTyped
in interface java.awt.event.KeyListener
public void keyPressed(java.awt.event.KeyEvent e)
keyPressed
in interface java.awt.event.KeyListener
public void keyReleased(java.awt.event.KeyEvent e)
keyReleased
in interface java.awt.event.KeyListener
e
- The key event in question.public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
e
- The action event in question.public void addActionListener(java.awt.event.ActionListener l)
l
- An action listener to be notified.public void removeActionListener(java.awt.event.ActionListener l)
l
- An action listener to be removed.protected void broadcastEvent(java.awt.event.ActionEvent e)
e
- An action event to be broadcast.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |