public final class AutoCompletion extends Object implements FocusListener, ComponentListener, HierarchyBoundsListener, DocumentListener, KeyListener, ActionListener, Runnable
JTextField
and optionally also to an existing JList
.Modifier and Type | Class and Description |
---|---|
static class |
AutoCompletion.AppendMode |
static class |
AutoCompletion.AutoSuggest |
static class |
AutoCompletion.ChoiceList
The list of all possible choices given the ``prefix'' typed by the user.
|
static class |
AutoCompletion.ChoiceRenderer
A kind of
ListCellRenderer which is capable of
properly rendering AutoCompletion.PossibleChoice . |
static interface |
AutoCompletion.Choices
Computes the list of all possible choices given the ``prefix''
typed by the user.
|
static class |
AutoCompletion.ChoicesBase
A possible base class for the classes implementing
AutoCompletion.Choices . |
static class |
AutoCompletion.MinimalChoices
A simple implementation where the computation of
AutoCompletion.ChoiceList
depends on the prefix typed by the user in the text field. |
static class |
AutoCompletion.NoChoices
Dummy implementation of choices which never finds any possible choice
whatever the specified prefix.
|
static interface |
AutoCompletion.PossibleChoice
A choice which can be disabled (that is, grayed).
|
static class |
AutoCompletion.ProgressTextField
Use this kind of text field rather than the stock
JTextField
if you need to support AutoCompletion.SlowChoices . |
static interface |
AutoCompletion.RichChoice
A choice which can have a description and a location.
|
static class |
AutoCompletion.RichChoiceRenderer
A kind of
ListCellRenderer which is capable of
properly rendering AutoCompletion.PossibleChoice and/or AutoCompletion.RichChoice . |
static class |
AutoCompletion.SimpleChoices
A simple implementation where the computation of
AutoCompletion.ChoiceList
does not depend on the prefix typed by the user
in the text field. |
static interface |
AutoCompletion.SlowChoices
Similar to
AutoCompletion.Choices , but the computation of the
AutoCompletion.ChoiceList is slow and as such, may
invoke a ProgressMonitor . |
Modifier and Type | Field and Description |
---|---|
static AutoCompletion.ChoiceRenderer |
CHOICE_RENDERER |
static AWTKeyStroke[] |
KEY_STROKES1
An array containing the Ctrl-SPACE key stroke.
|
static AWTKeyStroke[] |
KEY_STROKES2
An array containing the Ctrl-SPACE and
SPACE key strokes.
|
static AutoCompletion.NoChoices |
NO_CHOICES
A ready to use instance of NoChoices.
|
static AutoCompletion.RichChoiceRenderer |
RICH_CHOICE_RENDERER |
Constructor and Description |
---|
AutoCompletion() |
AutoCompletion(JTextField textField) |
public static final AutoCompletion.NoChoices NO_CHOICES
public static final AutoCompletion.ChoiceRenderer CHOICE_RENDERER
public static final AutoCompletion.RichChoiceRenderer RICH_CHOICE_RENDERER
public static final AWTKeyStroke[] KEY_STROKES1
setAppendKeyStrokes(java.awt.AWTKeyStroke[])
.KEY_STROKES2
public static final AWTKeyStroke[] KEY_STROKES2
setAppendKeyStrokes(java.awt.AWTKeyStroke[])
.KEY_STROKES1
public AutoCompletion()
public AutoCompletion(JTextField textField)
public static final String toString(Object object)
null
or is a ``disabled''
AutoCompletion.PossibleChoice
, returns null
.public static void simpleChoiceList(Object[] items, String prefix, AutoCompletion.ChoiceList choiceList)
AutoCompletion.SimpleChoices
.public static void minimalChoiceList(Object[] items, String prefix, AutoCompletion.ChoiceList choiceList)
AutoCompletion.MinimalChoices
.public static void setPreferMinimalChoices(boolean prefer)
public static boolean getPreferMinimalChoices()
public static void setDefaultAutoSuggest(AutoCompletion.AutoSuggest autoSuggest)
public static AutoCompletion.AutoSuggest getDefaultAutoSuggest()
public static void setDefaultAppendMode(AutoCompletion.AppendMode appendMode)
public static AutoCompletion.AppendMode getDefaultAppendMode()
public static void setDefaultAppendKeyStrokes(AWTKeyStroke[] keyStrokes)
public static AWTKeyStroke[] getDefaultAppendKeyStrokes()
public static void setDefaultVisibleSuggestionCount(int count)
public static int getDefaultVisibleSuggestionCount()
public void setTextField(JTextField textField)
public JTextField getTextField()
public void setList(JList<Object> list)
list
- the JList which is to be controlled by
this auto-completion facility. May be null
in which
case this facility creates its own JList (contained in a popup window).public void setChoices(AutoCompletion.Choices choices)
public AutoCompletion.Choices getChoices()
public void listChoices(String prefix, AutoCompletion.ChoiceList choiceList)
public void setAutoSuggest(AutoCompletion.AutoSuggest autoSuggest)
public AutoCompletion.AutoSuggest getAutoSuggest()
public void setAppendMode(AutoCompletion.AppendMode appendMode)
public AutoCompletion.AppendMode getAppendMode()
public void setAppendKeyStrokes(AWTKeyStroke[] keyStrokes)
public AWTKeyStroke[] getAppendKeyStrokes()
public void setVisibleSuggestionCount(int count)
public int getVisibleSuggestionCount()
public void setAppendOnAccept(boolean append)
public boolean getAppendOnAccept()
public void setEntry(String text)
Use this method rather than JTextField.setText(text)
,
for example in a MouseListener, when the JList has been created
by the client code.
public String acceptEntry()
public void actionPerformed(ActionEvent e)
actionPerformed
in interface ActionListener
public void focusLost(FocusEvent e)
focusLost
in interface FocusListener
public void focusGained(FocusEvent e)
focusGained
in interface FocusListener
public void componentResized(ComponentEvent e)
componentResized
in interface ComponentListener
public void componentMoved(ComponentEvent e)
componentMoved
in interface ComponentListener
public void componentShown(ComponentEvent e)
componentShown
in interface ComponentListener
public void componentHidden(ComponentEvent e)
componentHidden
in interface ComponentListener
public void ancestorMoved(HierarchyEvent e)
ancestorMoved
in interface HierarchyBoundsListener
public void ancestorResized(HierarchyEvent e)
ancestorResized
in interface HierarchyBoundsListener
public void insertUpdate(DocumentEvent e)
insertUpdate
in interface DocumentListener
public void removeUpdate(DocumentEvent e)
removeUpdate
in interface DocumentListener
public void changedUpdate(DocumentEvent e)
changedUpdate
in interface DocumentListener
public void suggest()
public void keyPressed(KeyEvent e)
keyPressed
in interface KeyListener
public void keyReleased(KeyEvent e)
keyReleased
in interface KeyListener
public void keyTyped(KeyEvent e)
keyTyped
in interface KeyListener