public class ComboBox<E> extends ComboBoxWithWidePopup<E> implements java.awt.event.AWTEventListener
JComboBox
implementation we provide
our own "patch". First of all it has correct preferred and minimum sizes that has sense
when combo box is editable. Also this implementation fixes some bugs with clicking
of default button. The SUN's combo box eats first "Enter" if the selected value from
the list and changed it. They say that combo box "commit" changes and only second
"Enter" clicks default button. This implementation clicks the default button
immediately. As the result of our patch combo box has internal wrapper for ComboBoxEditor.
It means that JComboBox.getEditor()
method always returns not the same value you set
by setEditor(ComboBoxEditor)
method. Moreover adding and removing of action listeners
isn't supported by the implementation of wrapper.javax.swing.JComboBox.AccessibleJComboBox, javax.swing.JComboBox.KeySelectionManager
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
protected boolean |
myPaintingNow |
static java.lang.String |
TABLE_CELL_EDITOR_PROPERTY |
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
Constructor and Description |
---|
ComboBox() |
ComboBox(javax.swing.ComboBoxModel<E> model) |
ComboBox(javax.swing.ComboBoxModel<E> model,
int width) |
ComboBox(E [] items) |
ComboBox(E [] items,
int width) |
ComboBox(int width) |
Modifier and Type | Method and Description |
---|---|
void |
addNotify() |
void |
eventDispatched(java.awt.AWTEvent event) |
java.awt.Dimension |
getMinimumSize() |
javax.swing.plaf.basic.ComboPopup |
getPopup() |
java.awt.Dimension |
getPreferredSize() |
void |
initBrowsableEditor(java.lang.Runnable browseAction,
Disposable parentDisposable) |
boolean |
isSwingPopup() |
void |
paint(java.awt.Graphics g) |
static void |
registerTableCellEditor(javax.swing.JComboBox comboBox,
javax.swing.table.TableCellEditor cellEditor) |
void |
registerTableCellEditor(javax.swing.table.TableCellEditor cellEditor) |
void |
removeNotify() |
void |
setEditor(javax.swing.ComboBoxEditor editor) |
void |
setKeySelectionManager(javax.swing.JComboBox.KeySelectionManager aManager) |
void |
setMinimumAndPreferredWidth(int minimumAndPreferredWidth) |
void |
setPopupVisible(boolean visible) |
void |
setSwingPopup(boolean swingPopup)
The
false parameter value enables JBPopup instead of
the default ComboBox popup. |
getMinimumPopupWidth, getMinLength, setMinLength, setRenderer
actionPerformed, actionPropertyChanged, addActionListener, addItem, addItemListener, addPopupMenuListener, configureEditor, configurePropertiesFromAction, contentsChanged, createActionPropertyChangeListener, createDefaultKeySelectionManager, fireActionEvent, fireItemStateChanged, firePopupMenuCanceled, firePopupMenuWillBecomeInvisible, firePopupMenuWillBecomeVisible, getAccessibleContext, getAction, getActionCommand, getActionListeners, getEditor, getItemAt, getItemCount, getItemListeners, getKeySelectionManager, getMaximumRowCount, getModel, getPopupMenuListeners, getPrototypeDisplayValue, getRenderer, getSelectedIndex, getSelectedItem, getSelectedObjects, getUI, getUIClassID, hidePopup, insertItemAt, installAncestorListener, intervalAdded, intervalRemoved, isEditable, isLightWeightPopupEnabled, isPopupVisible, paramString, processKeyBinding, processKeyEvent, removeActionListener, removeAllItems, removeItem, removeItemAt, removeItemListener, removePopupMenuListener, selectedItemChanged, selectWithKeyChar, setAction, setActionCommand, setEditable, setEnabled, setLightWeightPopupEnabled, setMaximumRowCount, setModel, setPrototypeDisplayValue, setSelectedIndex, setSelectedItem, setUI, showPopup, updateUI
addAncestorListener, 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, getNextFocusableComponent, getPopupLocation, 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, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, 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, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public static final java.lang.String TABLE_CELL_EDITOR_PROPERTY
protected boolean myPaintingNow
public ComboBox()
public ComboBox(int width)
public ComboBox(javax.swing.ComboBoxModel<E> model)
public ComboBox(E [] items)
public ComboBox(E [] items, int width)
public ComboBox(javax.swing.ComboBoxModel<E> model, int width)
public static void registerTableCellEditor(javax.swing.JComboBox comboBox, javax.swing.table.TableCellEditor cellEditor)
public void registerTableCellEditor(javax.swing.table.TableCellEditor cellEditor)
public void setPopupVisible(boolean visible)
setPopupVisible
in class javax.swing.JComboBox<E>
public void eventDispatched(java.awt.AWTEvent event)
eventDispatched
in interface java.awt.event.AWTEventListener
public void addNotify()
addNotify
in class javax.swing.JComponent
public void removeNotify()
removeNotify
in class javax.swing.JComponent
public javax.swing.plaf.basic.ComboPopup getPopup()
public void setSwingPopup(boolean swingPopup)
false
parameter value enables JBPopup instead of
the default ComboBox popup.swingPopup
- false
to enable JBPopupComboBoxPopupState
,
DarculaJBPopupComboPopup
public boolean isSwingPopup()
public void setKeySelectionManager(javax.swing.JComboBox.KeySelectionManager aManager)
setKeySelectionManager
in class javax.swing.JComboBox<E>
public void setMinimumAndPreferredWidth(int minimumAndPreferredWidth)
public final void setEditor(javax.swing.ComboBoxEditor editor)
setEditor
in class javax.swing.JComboBox<E>
public final java.awt.Dimension getMinimumSize()
getMinimumSize
in class javax.swing.JComponent
public java.awt.Dimension getPreferredSize()
getPreferredSize
in class javax.swing.JComponent
public void paint(java.awt.Graphics g)
paint
in class javax.swing.JComponent
public void initBrowsableEditor(java.lang.Runnable browseAction, Disposable parentDisposable)