Package org.jdesktop.swingx.autocomplete
Class ListAdaptor
- java.lang.Object
-
- org.jdesktop.swingx.autocomplete.AbstractAutoCompleteAdaptor
-
- org.jdesktop.swingx.autocomplete.ListAdaptor
-
- All Implemented Interfaces:
java.util.EventListener,javax.swing.event.ListSelectionListener
public class ListAdaptor extends AbstractAutoCompleteAdaptor implements javax.swing.event.ListSelectionListener
An implementation of the AbstractAutoCompleteAdaptor that is suitable for a JList in conjunction with a JTextComponent.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) javax.swing.JListlistthe list containing the items(package private) ObjectToStringConverterstringConverterthe converter used to transform items to strings(package private) javax.swing.text.JTextComponenttextComponentthe text component that is used for automatic completion
-
Constructor Summary
Constructors Constructor Description ListAdaptor(javax.swing.JList list, javax.swing.text.JTextComponent textComponent)Creates a new JListAdaptor for the given list and text component.ListAdaptor(javax.swing.JList list, javax.swing.text.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 java.lang.ObjectgetItem(int index)Returns the item at a given index.intgetItemCount()Returns the number of items in the list.java.lang.ObjectgetSelectedItem()Returns the currently selected item.javax.swing.text.JTextComponentgetTextComponent()Returns the text component that is being used for the automatic completion.voidsetSelectedItem(java.lang.Object item)Sets the selected item.voidvalueChanged(javax.swing.event.ListSelectionEvent listSelectionEvent)Implementation side effect - do not invoke.-
Methods inherited from class org.jdesktop.swingx.autocomplete.AbstractAutoCompleteAdaptor
getSelectedItemAsString, listContainsSelectedItem, markEntireText, markText, setSelectedItemAsString
-
-
-
-
Field Detail
-
list
javax.swing.JList list
the list containing the items
-
textComponent
javax.swing.text.JTextComponent textComponent
the text component that is used for automatic completion
-
stringConverter
ObjectToStringConverter stringConverter
the converter used to transform items to strings
-
-
Constructor Detail
-
ListAdaptor
public ListAdaptor(javax.swing.JList list, javax.swing.text.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(javax.swing.JList list, javax.swing.text.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(javax.swing.event.ListSelectionEvent listSelectionEvent)
Implementation side effect - do not invoke.- Specified by:
valueChangedin interfacejavax.swing.event.ListSelectionListener- Parameters:
listSelectionEvent- -
-
getSelectedItem
public java.lang.Object 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
public java.lang.Object getItem(int index)
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
public void setSelectedItem(java.lang.Object item)
Description copied from class:AbstractAutoCompleteAdaptorSets the selected item.- Specified by:
setSelectedItemin classAbstractAutoCompleteAdaptor- Parameters:
item- the item that is to be selected
-
getTextComponent
public javax.swing.text.JTextComponent 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
-
-