Package org.jdesktop.swingx.autocomplete
Class AutoCompleteComboBoxEditor
- java.lang.Object
-
- org.jdesktop.swingx.autocomplete.AutoCompleteComboBoxEditor
-
- All Implemented Interfaces:
javax.swing.ComboBoxEditor
public class AutoCompleteComboBoxEditor extends java.lang.Object implements javax.swing.ComboBoxEditor
Wrapper around the combobox editor that translates combobox items into strings. The methods setItem and getItem are modified to account for the string conversion.
This is necessary for those cases where the combobox items have no useful toString() method and a custom ObjectToStringConverter is used.
If we do not do this, the interaction between ComboBoxEditor and JComboBox will result in firing ActionListener events with the string value of ComboBoxEditor as the currently selected value.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Object
oldItem
last selected item(package private) ObjectToStringConverter
stringConverter
the converter used to convert items into their string representation(package private) javax.swing.ComboBoxEditor
wrapped
the original combo box editor
-
Constructor Summary
Constructors Constructor Description AutoCompleteComboBoxEditor(javax.swing.ComboBoxEditor wrapped, ObjectToStringConverter stringConverter)
Creates a new AutoCompleteComboBoxEditor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addActionListener(java.awt.event.ActionListener l)
java.awt.Component
getEditorComponent()
java.lang.Object
getItem()
void
removeActionListener(java.awt.event.ActionListener l)
void
selectAll()
void
setItem(java.lang.Object anObject)
-
-
-
Field Detail
-
wrapped
final javax.swing.ComboBoxEditor wrapped
the original combo box editor
-
stringConverter
final ObjectToStringConverter stringConverter
the converter used to convert items into their string representation
-
oldItem
private java.lang.Object oldItem
last selected item
-
-
Constructor Detail
-
AutoCompleteComboBoxEditor
public AutoCompleteComboBoxEditor(javax.swing.ComboBoxEditor wrapped, ObjectToStringConverter stringConverter)
Creates a new AutoCompleteComboBoxEditor.- Parameters:
wrapped
- the original ComboBoxEditor to be wrappedstringConverter
- the converter to use to convert items into their string representation.
-
-
Method Detail
-
getEditorComponent
public java.awt.Component getEditorComponent()
- Specified by:
getEditorComponent
in interfacejavax.swing.ComboBoxEditor
-
setItem
public void setItem(java.lang.Object anObject)
- Specified by:
setItem
in interfacejavax.swing.ComboBoxEditor
-
getItem
public java.lang.Object getItem()
- Specified by:
getItem
in interfacejavax.swing.ComboBoxEditor
-
selectAll
public void selectAll()
- Specified by:
selectAll
in interfacejavax.swing.ComboBoxEditor
-
addActionListener
public void addActionListener(java.awt.event.ActionListener l)
- Specified by:
addActionListener
in interfacejavax.swing.ComboBoxEditor
-
removeActionListener
public void removeActionListener(java.awt.event.ActionListener l)
- Specified by:
removeActionListener
in interfacejavax.swing.ComboBoxEditor
-
-