Package org.jdesktop.swingx.autocomplete
Class AbstractAutoCompleteAdaptor
- java.lang.Object
-
- org.jdesktop.swingx.autocomplete.AbstractAutoCompleteAdaptor
-
- Direct Known Subclasses:
ComboBoxAdaptor
,ListAdaptor
,TextComponentAdaptor
public abstract class AbstractAutoCompleteAdaptor extends java.lang.Object
This is the interface that binds the mechanism for automatic completion to a data model, a selection model (e.g. those used by JList, JComboBox and JTable) and the JTextComponent for which the automatic completion should happen. It is used to search and select a matching item and to mark the completed text inside the JTextComponent. Using this interface the mechanism for automatic completion is independent from the underlying data and selection model.- See Also:
ComboBoxAdaptor
,ListAdaptor
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
selectedItemAsString
the string representation in use for the currently selected item
-
Constructor Summary
Constructors Constructor Description AbstractAutoCompleteAdaptor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract java.lang.Object
getItem(int index)
Returns the item at a given index.abstract int
getItemCount()
Returns the number of items in the list.abstract java.lang.Object
getSelectedItem()
Returns the currently selected item.java.lang.String
getSelectedItemAsString()
Returns the string representation in use for the currently selected item.abstract javax.swing.text.JTextComponent
getTextComponent()
Returns the text component that is being used for the automatic completion.boolean
listContainsSelectedItem()
Returns true if the list contains the currently selected item.void
markEntireText()
Marks/selects the entire text that is displayed inside the text component.void
markText(int start)
Marks/selects the text that is displayed inside the text component starting from the character with index start.abstract void
setSelectedItem(java.lang.Object item)
Sets the selected item.void
setSelectedItemAsString(java.lang.String itemAsString)
Sets the string representation in use for the currently selected item.
-
-
-
Method Detail
-
getSelectedItem
public abstract java.lang.Object getSelectedItem()
Returns the currently selected item.- Returns:
- the selected item
-
setSelectedItem
public abstract void setSelectedItem(java.lang.Object item)
Sets the selected item.- Parameters:
item
- the item that is to be selected
-
getSelectedItemAsString
public java.lang.String getSelectedItemAsString()
Returns the string representation in use for the currently selected item.- Returns:
- the string representation in use for the currently selected item
-
setSelectedItemAsString
public void setSelectedItemAsString(java.lang.String itemAsString)
Sets the string representation in use for the currently selected item.- Parameters:
itemAsString
- the string representation in use for the currently selected item
-
getItemCount
public abstract int getItemCount()
Returns the number of items in the list.- Returns:
- the number of items in the list
-
getItem
public abstract java.lang.Object getItem(int index)
Returns the item at a given index. It is supposed that0<=index<getItemCount()
.- Parameters:
index
- the index of the item that is to be returned- Returns:
- the item at the given
index
-
listContainsSelectedItem
public boolean listContainsSelectedItem()
Returns true if the list contains the currently selected item.- Returns:
- true if the list contains the currently selected item.
-
getTextComponent
public abstract javax.swing.text.JTextComponent getTextComponent()
Returns the text component that is being used for the automatic completion.- Returns:
- the text component being used for the automatic completion
-
markEntireText
public void markEntireText()
Marks/selects the entire text that is displayed inside the text component.
-
markText
public void markText(int start)
Marks/selects the text that is displayed inside the text component starting from the character with index start.- Parameters:
start
- index of the first character that should be marked
-
-