Package org.jdesktop.swingx.autocomplete
Class ListAdaptor
- java.lang.Object
-
- org.jdesktop.swingx.autocomplete.AbstractAutoCompleteAdaptor
-
- org.jdesktop.swingx.autocomplete.ListAdaptor
-
- All Implemented Interfaces:
EventListener
,ListSelectionListener
public class ListAdaptor extends AbstractAutoCompleteAdaptor implements ListSelectionListener
An implementation of the AbstractAutoCompleteAdaptor that is suitable for a JList in conjunction with a JTextComponent.- Author:
- Thomas Bierhance
-
-
Constructor Summary
Constructors Constructor Description ListAdaptor(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
getItem(int index)
Returns the item at a given index.int
getItemCount()
Returns the number of items in the list.Object
getSelectedItem()
Returns the currently selected item.JTextComponent
getTextComponent()
Returns the text component that is being used for the automatic completion.void
setSelectedItem(Object item)
Sets the selected item.void
valueChanged(ListSelectionEvent listSelectionEvent)
Implementation side effect - do not invoke.-
Methods inherited from class org.jdesktop.swingx.autocomplete.AbstractAutoCompleteAdaptor
getSelectedItemAsString, listContainsSelectedItem, markEntireText, markText, setSelectedItemAsString
-
-
-
-
Constructor Detail
-
ListAdaptor
public ListAdaptor(JList list, JTextComponent textComponent)
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 Detail
-
valueChanged
public void valueChanged(ListSelectionEvent listSelectionEvent)
Implementation side effect - do not invoke.- Specified by:
valueChanged
in interfaceListSelectionListener
- Parameters:
listSelectionEvent
- -
-
getSelectedItem
public Object 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
public Object getItem(int index)
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
public void setSelectedItem(Object item)
Description copied from class:AbstractAutoCompleteAdaptor
Sets the selected item.- Specified by:
setSelectedItem
in classAbstractAutoCompleteAdaptor
- Parameters:
item
- the item that is to be selected
-
getTextComponent
public JTextComponent 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
-
-