Class ListAdaptor
java.lang.Object
org.jdesktop.swingx.autocomplete.AbstractAutoCompleteAdaptor
org.jdesktop.swingx.autocomplete.ListAdaptor
- All Implemented Interfaces:
EventListener, ListSelectionListener
An implementation of the AbstractAutoCompleteAdaptor that is suitable for a
JList in conjunction with a JTextComponent.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) JListthe list containing the items(package private) ObjectToStringConverterthe converter used to transform items to strings(package private) JTextComponentthe text component that is used for automatic completion -
Constructor Summary
ConstructorsConstructorDescriptionListAdaptor(JList list, JTextComponent textComponent) Creates a new JListAdaptor for the given list and text component.ListAdaptor(JList list, JTextComponent textComponent, ObjectToStringConverter stringConverter) Creates a new JListAdaptor for the given list and text component. -
Method Summary
Modifier and TypeMethodDescriptiongetItem(int index) Returns the item at a given index.intReturns the number of items in the list.Returns the currently selected item.Returns the text component that is being used for the automatic completion.voidsetSelectedItem(Object item) Sets the selected item.voidvalueChanged(ListSelectionEvent listSelectionEvent) Implementation side effect - do not invoke.Methods inherited from class AbstractAutoCompleteAdaptor
getSelectedItemAsString, listContainsSelectedItem, markEntireText, markText, setSelectedItemAsString
-
Field Details
-
list
JList listthe list containing the items -
textComponent
JTextComponent textComponentthe text component that is used for automatic completion -
stringConverter
ObjectToStringConverter stringConverterthe converter used to transform items to strings
-
-
Constructor Details
-
ListAdaptor
Creates a new JListAdaptor for the given list and text component.- Parameters:
list- the list that contains the items that are used for automatic completiontextComponent- the text component that will be used automatic completion
-
ListAdaptor
public ListAdaptor(JList list, JTextComponent textComponent, ObjectToStringConverter stringConverter) Creates a new JListAdaptor for the given list and text component.- Parameters:
list- the list that contains the items that are used for automatic completiontextComponent- the text component that will be used automatic completionstringConverter- the converter used to transform items to strings
-
-
Method Details
-
valueChanged
Implementation side effect - do not invoke.- Specified by:
valueChangedin interfaceListSelectionListener- Parameters:
listSelectionEvent- -
-
getSelectedItem
Description copied from class:AbstractAutoCompleteAdaptorReturns the currently selected item.- Specified by:
getSelectedItemin classAbstractAutoCompleteAdaptor- Returns:
- the selected item
-
getItemCount
public int getItemCount()Description copied from class:AbstractAutoCompleteAdaptorReturns the number of items in the list.- Specified by:
getItemCountin classAbstractAutoCompleteAdaptor- Returns:
- the number of items in the list
-
getItem
Description copied from class:AbstractAutoCompleteAdaptorReturns the item at a given index. It is supposed that0<=index<getItemCount().- Specified by:
getItemin 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:AbstractAutoCompleteAdaptorSets the selected item.- Specified by:
setSelectedItemin classAbstractAutoCompleteAdaptor- Parameters:
item- the item that is to be selected
-
getTextComponent
Description copied from class:AbstractAutoCompleteAdaptorReturns the text component that is being used for the automatic completion.- Specified by:
getTextComponentin classAbstractAutoCompleteAdaptor- Returns:
- the text component being used for the automatic completion
-