Sharkysoft home

lava.gui
Class KeystrokeBuffer

java.lang.Object
  |
  +--java.awt.event.KeyAdapter
        |
        +--lava.gui.KeystrokeBuffer
All Implemented Interfaces:
java.util.EventListener, java.awt.event.KeyListener

public class KeystrokeBuffer
extends java.awt.event.KeyAdapter

Buffers component keystrokes.

Details: A KeystrokeBuffer is a KeyAdapter that listens for and buffers all keyTyped calls. Calls to getKey return the next buffered character, or block until a character is typed. This class is thread-safe.

Version:
1999.04.24

Field Summary
protected  FifoQueue queue
          The keyTyped buffer.
 
Constructor Summary
KeystrokeBuffer()
          Constructs an instance of KeystrokeBuffer.
 
Method Summary
 int getKey()
          Returns the next character in the buffer, or blocks for a character if the queue is empty.
 void keyTyped(java.awt.event.KeyEvent e)
          Converts the given KeyEvent into a character and stored it in the buffer.
 
Methods inherited from class java.awt.event.KeyAdapter
keyPressed, keyReleased
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

queue

protected FifoQueue queue
The keyTyped buffer. Keytyped events are converted into Character objects and stored in this queue.
Constructor Detail

KeystrokeBuffer

public KeystrokeBuffer()
Constructs an instance of KeystrokeBuffer.
Method Detail

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Converts the given KeyEvent into a character and stored it in the buffer.
Overrides:
keyTyped in class java.awt.event.KeyAdapter
Parameters:
e - the KeyEvent

getKey

public int getKey()
Returns the next character in the buffer, or blocks for a character if the queue is empty.
Returns:
the next character

Sharkysoft home