Package org.jdesktop.swingx.autocomplete
Class TextComponentAdaptor
java.lang.Object
org.jdesktop.swingx.autocomplete.AbstractAutoCompleteAdaptor
org.jdesktop.swingx.autocomplete.TextComponentAdaptor
An implementation of the AbstractAutoCompleteAdaptor that is suitable for a
JTextComponent.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) List
<?> a List containing the strings to be used for automatic completion(package private) Object
the item that is currently selected(package private) JTextComponent
the text component that is used for automatic completion -
Constructor Summary
ConstructorsConstructorDescriptionTextComponentAdaptor
(JTextComponent textComponent, List<?> items) Creates a new TextComponentAdaptor for the given list and text component. -
Method Summary
Modifier and TypeMethodDescriptiongetItem
(int index) Returns the item at a given index.int
Returns the number of items in the list.Returns the currently selected item.Returns the text component that is being used for the automatic completion.void
setSelectedItem
(Object item) Sets the selected item.Methods inherited from class org.jdesktop.swingx.autocomplete.AbstractAutoCompleteAdaptor
getSelectedItemAsString, listContainsSelectedItem, markEntireText, markText, setSelectedItemAsString
-
Field Details
-
items
List<?> itemsa List containing the strings to be used for automatic completion -
textComponent
JTextComponent textComponentthe text component that is used for automatic completion -
selectedItem
Object selectedItemthe item that is currently selected
-
-
Constructor Details
-
TextComponentAdaptor
Creates a new TextComponentAdaptor for the given list and text component.- Parameters:
textComponent
- the text component that will be used automatic completionitems
- a List that contains the items that are used for automatic completion
-
-
Method Details
-
getSelectedItem
Description copied from class:AbstractAutoCompleteAdaptor
Returns the currently selected item.- Specified by:
getSelectedItem
in classAbstractAutoCompleteAdaptor
- Returns:
- the selected item
-
getItemCount
public int getItemCount()Description copied from class:AbstractAutoCompleteAdaptor
Returns the number of items in the list.- Specified by:
getItemCount
in classAbstractAutoCompleteAdaptor
- Returns:
- the number of items in the list
-
getItem
Description copied from class:AbstractAutoCompleteAdaptor
Returns the item at a given index. It is supposed that0<=index<getItemCount()
.- Specified by:
getItem
in classAbstractAutoCompleteAdaptor
- Parameters:
index
- the index of the item that is to be returned- Returns:
- the item at the given
index
-
setSelectedItem
Description copied from class:AbstractAutoCompleteAdaptor
Sets the selected item.- Specified by:
setSelectedItem
in classAbstractAutoCompleteAdaptor
- Parameters:
item
- the item that is to be selected
-
getTextComponent
Description copied from class:AbstractAutoCompleteAdaptor
Returns the text component that is being used for the automatic completion.- Specified by:
getTextComponent
in classAbstractAutoCompleteAdaptor
- Returns:
- the text component being used for the automatic completion
-