@DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class) public abstract class AbstractComboBoxBrowser<E> extends Object implements Serializable
JComboBox which provides auto completion
for the editable text in the drop down list in order to provide quick
browsing capabilities for the user.
Subclasses need to implement the update(java.lang.String) method in order to update
the combo box model with the actual auto completion data.
This class is designed to be minimal intrusive: It works with any subclass
of JComboBox and doesn't require a special
ComboBoxModel, although its specific behaviour will only show
if the JComboBox is editable and uses an
instance of a MutableComboBoxModel (which, besides the
editable property being set to true, is the
default for a plain JComboBox).
| Modifier and Type | Class and Description |
|---|---|
private class |
AbstractComboBoxBrowser.DecoratingComboBoxEditor
This proxy controls access to the real
ComboBoxEditor
installed by the client application or the pluggable look and feel. |
private class |
AbstractComboBoxBrowser.Listener |
| Modifier and Type | Field and Description |
|---|---|
private JComboBox<E> |
comboBox |
private AbstractComboBoxBrowser.Listener |
listener |
private boolean |
recursion
Used to inhibit mutual recursive event firing.
|
private static long |
serialVersionUID |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractComboBoxBrowser()
Creates a new combo box auto completion browser.
|
protected |
AbstractComboBoxBrowser(JComboBox<E> comboBox)
Creates a new combo box auto completion browser.
|
| Modifier and Type | Method and Description |
|---|---|
private void |
changeComboBox(JComboBox<E> oldCB,
JComboBox<E> newCB,
boolean update) |
private void |
changeDocument(Document oldDoc,
Document newDoc,
boolean update) |
private void |
changeEditor(ComboBoxEditor oldCBE,
ComboBoxEditor newCBE,
boolean update) |
private void |
changeText(JTextComponent oldTC,
JTextComponent newTC,
boolean update) |
private void |
documentUpdated() |
JComboBox<E> |
getComboBox()
Returns the combo box which this object is auto completing.
|
private boolean |
lock()
Locks out mutual recursive event notification.
|
void |
setComboBox(JComboBox<E> comboBox)
Sets the combo box which this object is auto completing and updates
the drop down list with the auto completion for the currently selected
item.
|
private void |
unlock()
Unlocks mutual recursive event notification.
|
protected abstract boolean |
update(String initials)
Subclasses are expected to update the auto completion elements in the
model of this combo box based on the specified
initials. |
private void |
updateEditor(ComboBoxEditor cbe,
Object item) |
@CheckForNull private JComboBox<E> comboBox
private final AbstractComboBoxBrowser.Listener listener
private transient boolean recursion
private static final long serialVersionUID
protected AbstractComboBoxBrowser()
setComboBox(javax.swing.JComboBox<E>) must be called in order to use this object.protected AbstractComboBoxBrowser(@CheckForNull JComboBox<E> comboBox)
update(java.lang.String)
and hence the drop down list of the combo box is left unchanged.comboBox - The combo box to enable browsing for auto completions.
May be null.private void changeComboBox(@CheckForNull JComboBox<E> oldCB, @CheckForNull JComboBox<E> newCB, boolean update)
private void changeDocument(@CheckForNull Document oldDoc, @CheckForNull Document newDoc, boolean update)
private void changeEditor(@CheckForNull ComboBoxEditor oldCBE, @CheckForNull ComboBoxEditor newCBE, boolean update)
private void changeText(@CheckForNull JTextComponent oldTC, @CheckForNull JTextComponent newTC, boolean update)
private void documentUpdated()
@Nullable public JComboBox<E> getComboBox()
null.private boolean lock()
public void setComboBox(@CheckForNull JComboBox<E> comboBox)
comboBox - The combo box to enable browsing for auto completions.
May be null.private void unlock()
protected abstract boolean update(@CheckForNull String initials)
initials.
They should not do any other work within this method.
In particular, they should not update the visual appearance of this
component.
getComboBox() is guaranteed to return non-null if
this method is called from this abstract base class.
initials - The text to auto complete. May be null.private void updateEditor(ComboBoxEditor cbe, @CheckForNull Object item)
Copyright © 2004-2011 Schlichtherle IT Services. All Rights Reserved.