public class AutoCompleteDecorator extends Object
Usage examples:
JComboBox comboBox = [...];
AutoCompleteDecorator.decorate(comboBox);
List items = [...];
JTextField textField = [...];
AutoCompleteDecorator.decorate(textField, items);
JList list = [...];
JTextField textField = [...];
AutoCompleteDecorator.decorate(list, textField);
Modifier and Type | Class and Description |
---|---|
(package private) static class |
AutoCompleteDecorator.NonStrictBackspaceAction |
Modifier and Type | Field and Description |
---|---|
private static List<String> |
COMBO_BOX_ACTIONS |
private static Object |
errorFeedbackAction
A TextAction that provides an error feedback for the text component that invoked
the action.
|
Modifier | Constructor and Description |
---|---|
private |
AutoCompleteDecorator() |
Modifier and Type | Method and Description |
---|---|
(package private) static AutoCompleteDocument |
createAutoCompleteDocument(AbstractAutoCompleteAdaptor adaptor,
boolean strictMatching,
ObjectToStringConverter stringConverter,
Document delegate) |
static void |
decorate(JComboBox comboBox)
Enables automatic completion for the given JComboBox.
|
static void |
decorate(JComboBox comboBox,
ObjectToStringConverter stringConverter)
Enables automatic completion for the given JComboBox.
|
static void |
decorate(JList list,
JTextComponent textComponent)
Enables automatic completion for the given JTextComponent based on the
items contained in the given JList.
|
static void |
decorate(JList list,
JTextComponent textComponent,
ObjectToStringConverter stringConverter)
Enables automatic completion for the given JTextComponent based on the
items contained in the given JList.
|
static void |
decorate(JTextComponent textComponent,
AutoCompleteDocument document,
AbstractAutoCompleteAdaptor adaptor)
Decorates a given text component for automatic completion using the
given AutoCompleteDocument and AbstractAutoCompleteAdaptor.
|
static void |
decorate(JTextComponent textComponent,
List<?> items,
boolean strictMatching)
Enables automatic completion for the given JTextComponent based on the
items contained in the given List.
|
static void |
decorate(JTextComponent textComponent,
List<?> items,
boolean strictMatching,
ObjectToStringConverter stringConverter)
Enables automatic completion for the given JTextComponent based on the
items contained in the given List.
|
private static void |
installMap(InputMap componentMap,
boolean strict) |
(package private) static void |
undecorate(JComboBox comboBox) |
(package private) static void |
undecorate(JList list) |
(package private) static void |
undecorate(JTextComponent textComponent) |
private static final List<String> COMBO_BOX_ACTIONS
private static final Object errorFeedbackAction
private AutoCompleteDecorator()
private static void installMap(InputMap componentMap, boolean strict)
static AutoCompleteDocument createAutoCompleteDocument(AbstractAutoCompleteAdaptor adaptor, boolean strictMatching, ObjectToStringConverter stringConverter, Document delegate)
public static void decorate(JComboBox comboBox)
comboBox
- a combo boxdecorate(JComboBox, ObjectToStringConverter)
public static void decorate(JComboBox comboBox, ObjectToStringConverter stringConverter)
Note: the AutoCompleteDecorator
will alter the state of
the JComboBox
to be editable. This can cause side effects with
layouts and sizing. JComboBox
caches the size, which differs
depending on the component's editability. Therefore, if the component's
size is accessed prior to being decorated and then the cached size is
forced to be recalculated, the size of the component will change.
Because the size of the component can be altered (recalculated), the
decorator does not attempt to set any sizes on the supplied
JComboBox
. Users that need to ensure sizes of supplied combos
should take measures to set the size of the combo.
comboBox
- a combo boxstringConverter
- the converter used to transform items to stringsstatic void undecorate(JComboBox comboBox)
public static void decorate(JList list, JTextComponent textComponent)
list
- a JList containing the items for automatic completiontextComponent
- the text component that will be enabled for automatic
completionpublic static void decorate(JList list, JTextComponent textComponent, ObjectToStringConverter stringConverter)
list
- a JList containing the items for automatic completiontextComponent
- the text component that will be used for automatic
completionstringConverter
- the converter used to transform items to stringsstatic void undecorate(JList list)
public static void decorate(JTextComponent textComponent, List<?> items, boolean strictMatching)
textComponent
- the text component that will be used for automatic
completion.items
- contains the items that are used for autocompletionstrictMatching
- true, if only given items should be allowed to be enteredpublic static void decorate(JTextComponent textComponent, List<?> items, boolean strictMatching, ObjectToStringConverter stringConverter)
items
- contains the items that are used for autocompletiontextComponent
- the text component that will be used for automatic
completion.strictMatching
- true, if only given items should be allowed to be enteredstringConverter
- the converter used to transform items to stringspublic static void decorate(JTextComponent textComponent, AutoCompleteDocument document, AbstractAutoCompleteAdaptor adaptor)
textComponent
- a text component that should be decorateddocument
- the AutoCompleteDocument to be installed on the text componentadaptor
- the AbstractAutoCompleteAdaptor to be usedstatic void undecorate(JTextComponent textComponent)
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses