edu.washington.biostr.sig.brainj3d.shwing.swing
Class AutoComplete

java.lang.Object
  extended by edu.washington.biostr.sig.brainj3d.shwing.swing.AutoComplete
All Implemented Interfaces:
ActionListener, ComponentListener, FocusListener, KeyListener, MouseListener, MouseMotionListener, EventListener, DocumentListener, ListSelectionListener

public class AutoComplete
extends Object
implements KeyListener, ActionListener, ComponentListener, DocumentListener, ListSelectionListener, MouseListener, FocusListener, MouseMotionListener

This provides autocomplete functionality for a text box. It monitors the focus, keys and document to determine what is going on. When the document changes, it makes suggestions if possible. The down key or up key changes the selection on the suggestion list and fills in the form with highlighted text and keeps the focus on the text field. Clicking on the list fills in the form may fire an action event. If the text field fires, then the text is added to this AutoComplete unless autoAdd is false.

Author:
Eider Moore

Constructor Summary
AutoComplete(JTextField owner)
          Create a new AutoComplete and register owner as the owner.
AutoComplete(JTextField owner, AutoCompleteModel model)
          Create a new AutoComplete and register owner as the owner.
 
Method Summary
 void actionPerformed(ActionEvent e)
           
 void add(String text)
          Add the specified text to the set of text that will be suggested.
 void addAll(Collection c)
          Add all of the collection of String's to the set of suggestions.
 void changedUpdate(DocumentEvent e)
           
 void componentHidden(ComponentEvent e)
           
 void componentMoved(ComponentEvent e)
           
 void componentResized(ComponentEvent e)
           
 void componentShown(ComponentEvent e)
           
 boolean equals(Object obj)
           
 void focusGained(FocusEvent e)
           
 void focusLost(FocusEvent e)
           
 Component getDisplayOwner()
           
 AutoCompleteModel getModel()
          Get the set of suggestions.
 int hashCode()
           
 void hide()
           
 void insertUpdate(DocumentEvent e)
           
 void install(JTextField owner)
          Attach this autocomplete to this owner.
 void keyPressed(KeyEvent e)
          Look for down arrows to transfer focus.
 void keyReleased(KeyEvent e)
           
 void keyTyped(KeyEvent e)
           
 void mouseClicked(MouseEvent e)
           
 void mouseDragged(MouseEvent e)
           
 void mouseEntered(MouseEvent e)
           
 void mouseExited(MouseEvent e)
           
 void mouseMoved(MouseEvent e)
           
 void mousePressed(MouseEvent e)
           
 void mouseReleased(MouseEvent e)
           
protected  void moveToIndex(int index)
           
protected  void quickHide()
           
protected  Popup quickShow()
           
 void removeUpdate(DocumentEvent e)
           
 void reshow()
           
 void setDisplayOwner(Component displayOwner)
           
 void setModel(AutoCompleteModel model)
           
 void show()
           
 void uninstall()
          Remove this text field from this owner.
 void valueChanged(ListSelectionEvent e)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AutoComplete

public AutoComplete(JTextField owner)
Create a new AutoComplete and register owner as the owner. Set the model to be model.


AutoComplete

public AutoComplete(JTextField owner,
                    AutoCompleteModel model)
Create a new AutoComplete and register owner as the owner. Set the model to be model.

Method Detail

install

public void install(JTextField owner)
Attach this autocomplete to this owner.

Parameters:
owner -

setDisplayOwner

public void setDisplayOwner(Component displayOwner)

getDisplayOwner

public Component getDisplayOwner()

uninstall

public void uninstall()
Remove this text field from this owner.

Parameters:
owner -

keyTyped

public void keyTyped(KeyEvent e)
Specified by:
keyTyped in interface KeyListener

show

public void show()

quickShow

protected Popup quickShow()

reshow

public void reshow()

quickHide

protected void quickHide()

hide

public void hide()

keyPressed

public void keyPressed(KeyEvent e)
Look for down arrows to transfer focus. And redirect any key stroke to the component.

Specified by:
keyPressed in interface KeyListener
See Also:
KeyListener.keyPressed(java.awt.event.KeyEvent)

moveToIndex

protected void moveToIndex(int index)

keyReleased

public void keyReleased(KeyEvent e)
Specified by:
keyReleased in interface KeyListener

actionPerformed

public void actionPerformed(ActionEvent e)
Specified by:
actionPerformed in interface ActionListener

componentHidden

public void componentHidden(ComponentEvent e)
Specified by:
componentHidden in interface ComponentListener

componentMoved

public void componentMoved(ComponentEvent e)
Specified by:
componentMoved in interface ComponentListener

componentResized

public void componentResized(ComponentEvent e)
Specified by:
componentResized in interface ComponentListener

componentShown

public void componentShown(ComponentEvent e)
Specified by:
componentShown in interface ComponentListener

changedUpdate

public void changedUpdate(DocumentEvent e)
Specified by:
changedUpdate in interface DocumentListener

insertUpdate

public void insertUpdate(DocumentEvent e)
Specified by:
insertUpdate in interface DocumentListener

removeUpdate

public void removeUpdate(DocumentEvent e)
Specified by:
removeUpdate in interface DocumentListener

valueChanged

public void valueChanged(ListSelectionEvent e)
Specified by:
valueChanged in interface ListSelectionListener

mouseClicked

public void mouseClicked(MouseEvent e)
Specified by:
mouseClicked in interface MouseListener

mouseEntered

public void mouseEntered(MouseEvent e)
Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent e)
Specified by:
mouseExited in interface MouseListener

mousePressed

public void mousePressed(MouseEvent e)
Specified by:
mousePressed in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent e)
Specified by:
mouseReleased in interface MouseListener

focusGained

public void focusGained(FocusEvent e)
Specified by:
focusGained in interface FocusListener

focusLost

public void focusLost(FocusEvent e)
Specified by:
focusLost in interface FocusListener

add

public void add(String text)
Add the specified text to the set of text that will be suggested.

Parameters:
text -

addAll

public void addAll(Collection c)
Add all of the collection of String's to the set of suggestions.

Parameters:
c -

getModel

public AutoCompleteModel getModel()
Get the set of suggestions. If it is being shared, only one autocomplete can be shown properly at a time.

Returns:

setModel

public void setModel(AutoCompleteModel model)

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

mouseDragged

public void mouseDragged(MouseEvent e)
Specified by:
mouseDragged in interface MouseMotionListener

mouseMoved

public void mouseMoved(MouseEvent e)
Specified by:
mouseMoved in interface MouseMotionListener


Copyright © 2006 University of Washington. All Rights Reserved.