public class JXComboBox extends JComboBox
JComboBox
that provides the following additional functionality:
Auto-starts edits correctly for AutoCompletion when inside a JTable
. A normal JComboBox
fails to recognize the first key stroke when it has been
decorated
.
Adds highlighting support.
Modifier and Type | Class and Description |
---|---|
protected static class |
JXComboBox.ComboBoxAdapter |
class |
JXComboBox.DelegatingRenderer
A decorator for the original ListCellRenderer.
|
(package private) class |
JXComboBox.StringValueKeySelectionManager |
JComboBox.AccessibleJComboBox, JComboBox.KeySelectionManager
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
private CompoundHighlighter |
compoundHighlighter |
private JXComboBox.ComboBoxAdapter |
dataAdapter |
private JXComboBox.DelegatingRenderer |
delegatingRenderer |
private ChangeListener |
highlighterChangeListener |
private boolean |
isDispatching |
private List<KeyEvent> |
pendingEvents |
private StringValueRegistry |
stringValueRegistry |
private boolean |
updatingUI |
private boolean |
useHighlightersForCurrentValue |
actionCommand, dataModel, editor, isEditable, keySelectionManager, lightWeightPopupEnabled, maximumRowCount, renderer, selectedItemReminder
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
JXComboBox()
Creates a
JXComboBox with a default data model. |
JXComboBox(ComboBoxModel model)
Creates a
JXComboBox that takes its items from an existing
ComboBoxModel . |
JXComboBox(Object[] items)
Creates a
JXComboBox that contains the elements in the specified array. |
JXComboBox(Vector<?> items)
Creates a
JXComboBox that contains the elements in the specified Vector. |
Modifier and Type | Method and Description |
---|---|
void |
addHighlighter(Highlighter highlighter)
Adds a Highlighter.
|
protected ListCellRenderer |
createDefaultCellRenderer()
Creates and returns the default cell renderer to use.
|
protected JComboBox.KeySelectionManager |
createDefaultKeySelectionManager()
This implementation uses the
StringValue representation of the elements to determine
the selected item. |
protected StringValueRegistry |
createDefaultStringValueRegistry()
Creates and returns the default registry for StringValues.
|
protected ChangeListener |
createHighlighterChangeListener()
Creates and returns the ChangeListener observing Highlighters.
|
protected ComponentAdapter |
getComponentAdapter() |
protected ComponentAdapter |
getComponentAdapter(int index)
Convenience to access a configured ComponentAdapter.
|
private CompoundHighlighter |
getCompoundHighlighter()
Returns the CompoundHighlighter assigned to the table, null if none.
|
private JXComboBox.DelegatingRenderer |
getDelegatingRenderer() |
protected ChangeListener |
getHighlighterChangeListener()
Returns the
ChangeListener to use with highlighters. |
Highlighter[] |
getHighlighters()
Returns the
Highlighter s used by this column. |
protected static JList |
getPopupListFor(JComboBox comboBox) |
ListCellRenderer |
getRenderer()
Overridden to return the delegating renderer which is wrapped around the
original to support highlighting.
|
String |
getStringAt(int row)
Returns the string representation of the cell value at the given position.
|
protected StringValueRegistry |
getStringValueRegistry()
Returns the StringValueRegistry which defines the string representation for
each cells.
|
ListCellRenderer |
getWrappedRenderer()
Returns the renderer installed by client code or the default if none has
been set.
|
private void |
init() |
private boolean |
isStartingCellEdit(KeyEvent e) |
boolean |
isUseHighlightersForCurrentValue()
PENDING JW to KS: review method naming - doesn't sound like valid English to me (no
native speaker of course :-).
|
protected boolean |
processKeyBinding(KeyStroke ks,
KeyEvent e,
int condition,
boolean pressed) |
void |
removeHighlighter(Highlighter highlighter)
Removes the given Highlighter.
|
private void |
setCompoundHighlighter(CompoundHighlighter pipeline)
Assigns a CompoundHighlighter to the table, maybe null to remove all Highlighters.
|
void |
setHighlighters(Highlighter... highlighters)
Sets the
Highlighter s to the column, replacing any old settings. |
void |
setRenderer(ListCellRenderer renderer)
Overridden to wrap the given renderer in a DelegatingRenderer to support
highlighting.
|
void |
setUseHighlightersForCurrentValue(boolean useHighlightersForCurrentValue) |
void |
updateUI()
Overridden to update renderer and highlighters.
|
actionPerformed, actionPropertyChanged, addActionListener, addItem, addItemListener, addPopupMenuListener, configureEditor, configurePropertiesFromAction, contentsChanged, createActionPropertyChangeListener, fireActionEvent, fireItemStateChanged, firePopupMenuCanceled, firePopupMenuWillBecomeInvisible, firePopupMenuWillBecomeVisible, getAccessibleContext, getAction, getActionCommand, getActionListeners, getEditor, getItemAt, getItemCount, getItemListeners, getKeySelectionManager, getMaximumRowCount, getModel, getPopupMenuListeners, getPrototypeDisplayValue, getSelectedIndex, getSelectedItem, getSelectedObjects, getUI, getUIClassID, hidePopup, insertItemAt, installAncestorListener, intervalAdded, intervalRemoved, isEditable, isLightWeightPopupEnabled, isPopupVisible, paramString, processKeyEvent, removeActionListener, removeAllItems, removeItem, removeItemAt, removeItemListener, removePopupMenuListener, selectedItemChanged, selectWithKeyChar, setAction, setActionCommand, setEditable, setEditor, setEnabled, setKeySelectionManager, setLightWeightPopupEnabled, setMaximumRowCount, setModel, setPopupVisible, setPrototypeDisplayValue, setSelectedIndex, setSelectedItem, setUI, showPopup
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
private JXComboBox.ComboBoxAdapter dataAdapter
private JXComboBox.DelegatingRenderer delegatingRenderer
private StringValueRegistry stringValueRegistry
private boolean useHighlightersForCurrentValue
private CompoundHighlighter compoundHighlighter
private ChangeListener highlighterChangeListener
private List<KeyEvent> pendingEvents
private boolean isDispatching
private boolean updatingUI
public JXComboBox()
JXComboBox
with a default data model. The default data model is an
empty list of objects. Use addItem
to add items. By default the first item in
the data model becomes selected.DefaultComboBoxModel
public JXComboBox(ComboBoxModel model)
JXComboBox
that takes its items from an existing
ComboBoxModel
. Since the ComboBoxModel
is provided, a combo box
created using this constructor does not create a default combo box model and may impact how
the insert, remove and add methods behave.model
- the ComboBoxModel
that provides the displayed list of itemsDefaultComboBoxModel
public JXComboBox(Object[] items)
JXComboBox
that contains the elements in the specified array. By
default the first item in the array (and therefore the data model) becomes selected.items
- an array of objects to insert into the combo boxDefaultComboBoxModel
public JXComboBox(Vector<?> items)
JXComboBox
that contains the elements in the specified Vector. By
default the first item in the vector (and therefore the data model) becomes selected.items
- an array of vectors to insert into the combo boxDefaultComboBoxModel
private void init()
protected static JList getPopupListFor(JComboBox comboBox)
protected JComboBox.KeySelectionManager createDefaultKeySelectionManager()
This implementation uses the StringValue
representation of the elements to determine
the selected item.
createDefaultKeySelectionManager
in class JComboBox
protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed)
processKeyBinding
in class JComboBox
private boolean isStartingCellEdit(KeyEvent e)
protected ComponentAdapter getComponentAdapter()
protected ComponentAdapter getComponentAdapter(int index)
index
- the row index in view coordinates, must be valid.protected StringValueRegistry getStringValueRegistry()
Currently exposed for testing reasons, client code is recommended to not use nor override.
protected StringValueRegistry createDefaultStringValueRegistry()
public String getStringAt(int row)
row
- the row index of the cell in view coordinatesprivate JXComboBox.DelegatingRenderer getDelegatingRenderer()
protected ListCellRenderer createDefaultCellRenderer()
DefaultListRenderer
.public ListCellRenderer getRenderer()
Overridden to return the delegating renderer which is wrapped around the original to support highlighting. The returned renderer is of type DelegatingRenderer and guaranteed to not-null
getRenderer
in class JComboBox
setRenderer(ListCellRenderer)
,
JXComboBox.DelegatingRenderer
public ListCellRenderer getWrappedRenderer()
setRenderer(ListCellRenderer)
public void setRenderer(ListCellRenderer renderer)
Overridden to wrap the given renderer in a DelegatingRenderer to support highlighting.
Note: the wrapping implies that the renderer returned from the getCellRenderer
is not the renderer as given here, but the wrapper. To access the original,
use getWrappedCellRenderer
.
setRenderer
in class JComboBox
getWrappedRenderer()
,
getRenderer()
public boolean isUseHighlightersForCurrentValue()
true
if the combo box decorates the current value with highlighters; false
otherwisepublic void setUseHighlightersForCurrentValue(boolean useHighlightersForCurrentValue)
private CompoundHighlighter getCompoundHighlighter()
setCompoundHighlighter(CompoundHighlighter)
private void setCompoundHighlighter(CompoundHighlighter pipeline)
The default value is null
.
PENDING: open up for subclasses again?.
pipeline
- the CompoundHighlighter to use for renderer decoration.getCompoundHighlighter()
,
addHighlighter(Highlighter)
,
removeHighlighter(Highlighter)
public void setHighlighters(Highlighter... highlighters)
Highlighter
s to the column, replacing any old settings. None of the
given Highlighters must be null.
highlighters
- zero or more not null highlighters to use for renderer decoration.getHighlighters()
,
addHighlighter(Highlighter)
,
removeHighlighter(Highlighter)
public Highlighter[] getHighlighters()
Highlighter
s used by this column. Maybe empty, but guarantees to be
never null.setHighlighters(Highlighter[])
public void addHighlighter(Highlighter highlighter)
highlighter
- the Highlighter
to add.NullPointerException
- if Highlighter
is null.removeHighlighter(Highlighter)
,
setHighlighters(Highlighter[])
public void removeHighlighter(Highlighter highlighter)
Does nothing if the Highlighter is not contained.
highlighter
- the Highlighter to remove.addHighlighter(Highlighter)
,
setHighlighters(Highlighter...)
protected ChangeListener getHighlighterChangeListener()
ChangeListener
to use with highlighters. Lazily creates the
listener.not-null
protected ChangeListener createHighlighterChangeListener()
A property change event is create for a state change.
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses