edu.northwestern.at.utils.swing
Class ComboBoxMultipleKeySelectionManager

java.lang.Object
  extended by edu.northwestern.at.utils.swing.ComboBoxMultipleKeySelectionManager
All Implemented Interfaces:
javax.swing.JComboBox.KeySelectionManager

public class ComboBoxMultipleKeySelectionManager
extends java.lang.Object
implements javax.swing.JComboBox.KeySelectionManager

Combobox key selection manager which selects items using multiple characters.

Based upon an example in the Java Developer's Almanac 1.4 by Patrick Chan.


Field Summary
protected  long lastKeyTime
          Time at which last key was typed.
protected  long maximumKeyArrivalInterval
          Number of milliseconds under which a new keystroke is assumed to be appended to the previous to form a search string.
protected  java.lang.String pattern
          Accumulates key strokes that are typed less then "keyInterval" milliseconds apart.
 
Constructor Summary
ComboBoxMultipleKeySelectionManager()
           
 
Method Summary
 int selectionForKey(char aKey, javax.swing.ComboBoxModel model)
          Handle selection when a key arrives.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lastKeyTime

protected long lastKeyTime
Time at which last key was typed.


pattern

protected java.lang.String pattern
Accumulates key strokes that are typed less then "keyInterval" milliseconds apart.


maximumKeyArrivalInterval

protected long maximumKeyArrivalInterval
Number of milliseconds under which a new keystroke is assumed to be appended to the previous to form a search string.

Constructor Detail

ComboBoxMultipleKeySelectionManager

public ComboBoxMultipleKeySelectionManager()
Method Detail

selectionForKey

public int selectionForKey(char aKey,
                           javax.swing.ComboBoxModel model)
Handle selection when a key arrives.

Specified by:
selectionForKey in interface javax.swing.JComboBox.KeySelectionManager
Parameters:
aKey - The typed key.
model - The ComboBoxModel.
Returns:
Index of matching entry, or -1 if none.