| java.lang.Object com.jidesoft.swing.AutoCompletion
AutoCompletion | public class AutoCompletion (Code) | | AutoCompletion is a helper class to make JTextComponent or JComboBox auto-complete based
on a list of known items.
There are three constructors. The simplest one is
AutoCompletion.AutoCompletion(javax.swing.JComboBox) .
It takes any combobox and make it auto completion. If you are looking for an auto-complete combobox solution,
this is all you need. However AutoCompletion can do more than that. There are two more constrcutors.
One is
AutoCompletion.AutoCompletion(javax.swing.text.JTextComponent,Searchable) .
It will use
Searchable which is another component available in JIDE to
make the JTextCompoent auto-complete. We used Searchable here because it provides
a common interface to access the element in JTree, JList or JTable. In
the other word, the known list item we used to auto-complete can be got
from JTree or JList or even JTable or any other component as
long as it has Searchable interface implemented.
The last constrcutor takes any java.util.List and use it as auto completion list.
The only option available on AutoCompletion is
AutoCompletion.setStrict(boolean) . If it's true, it will not allow
user to type in anything that is not in the known item list. If false, user can type in whatever he/she wants. If the text
can match with a item in the known item list, it will still auto-complete.
author: Thomas Bierhance author: JIDE Software, Inc. |
Inner Class :protected class AutoCompletionDocument extends PlainDocument | |
createDocument | protected AutoCompletionDocument createDocument()(Code) | | Creates AutoCompletionDocument.
the AutoCompletionDocument. |
getTextComponent | protected JTextComponent getTextComponent()(Code) | | Gets the underlying text component which auto-completes.
the underlying text component. |
installListeners | public void installListeners()(Code) | | Installs the listeners needed for auto-completion feature.
Please note, this method is already called when you create AutoCompletion.
Unless you called
AutoCompletion.uninstallListeners() , there is no need to call this method yourself.
|
isStrict | public boolean isStrict()(Code) | | Gets the strict property.
the value of strict property. |
setStrict | public void setStrict(boolean strict)(Code) | | Sets the strict property. If true, it will not allow user to type in anything
that is not in the known item list. If false, user can type in whatever he/she wants. If the text
can match with a item in the known item list, it will still auto-complete.
Parameters: strict - |
setStrictCompletion | public void setStrictCompletion(boolean strictCompletion)(Code) | | Sets the strict completion property. If true, in case insensitive searching,
it will always use the exact item in the Searchable to replace whatever user types. For example,
when Searchable has an item "Arial" and user types in "AR", if this flag is true, it will autocompleted
as "Arial". If false, it will be autocompleted as "ARial". Of course, this flag will only
make a difference if Searchable is case insensitive.
Parameters: strictCompletion - |
uninstallListeners | public void uninstallListeners()(Code) | | Uninstalls the listeners so that the component is not auto-completion anymore.
|
|
|