JIDE 3.5.15

com.jidesoft.combobox
Class AbstractComboBox

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.jidesoft.combobox.AbstractComboBox
All Implemented Interfaces:
ConverterContextSupport, AlignmentSupport, ActionListener, FocusListener, MouseListener, ImageObserver, ItemSelectable, MenuContainer, Serializable, EventListener, Accessible, PopupMenuListener
Direct Known Subclasses:
AbstractFileComboBox, CalculatorComboBox, ColorComboBox, DateComboBox, FolderChooserComboBox, FolderNameChooserComboBox, FontComboBox, InsetsComboBox, ListComboBox, MultilineStringComboBox, MultiSelectListComboBox, NumberSpinnerComboBox, StringArrayComboBox, TableComboBox, TreeComboBox

public abstract class AbstractComboBox
extends JComponent
implements ItemSelectable, MouseListener, ActionListener, ConverterContextSupport, AlignmentSupport, PopupMenuListener, FocusListener, Accessible

This class provides default implementation of any ComboBox-like component. With this class, you can fully customize the dropdown popup or even show popup as dialog. You can also customize the button and the text field to whatever you want. All you need is to create a class which extends AbstractComboBox and implements several methods.
Any combobox-like component can be divided into several parts. They are an editor such as a JTextField, a button which shows the popup and a popup which will be shown when button is pressed.
There are also two types of ComboBox. One is the popup shown as drop down, same as JComboBox. The other one is the popup shown as dialog such as a text field which can choose a file. So when you construct AbstractComboBox, you can pass in type either as DROPDOWN or as POPUP.
This class doesn't extend JComboBox. However all interfaces in JComboBox are divided into two parts and put in AbstractComboBox or ListComboBox, whichever makes senses. So you shouldn't see much problem if converting existing JComboBox implementation to AbstractComboBox and ListComboBox implementation.

If you extend this class to create your own ComboBox, make sure you call initComponent() or initComponent(javax.swing.ComboBoxModel) method in your ComboBox's constructor. We didn't call it automatically because we want you to decide when to call it during your ComboBox's initialization steps.

See Also:
Serialized Form

Nested Class Summary
protected  class AbstractComboBox.AccessibleJComboBox
          This class implements accessibility support for the JComboBox class.
static class AbstractComboBox.ComboBoxSpinner
           
static class AbstractComboBox.ComboBoxTextField
           
 class AbstractComboBox.DefaultRendererComponent
           
 class AbstractComboBox.DefaultTextFieldEditorComponent
          Default EditorComponent which has a text field.
 class AbstractComboBox.EditorComponent
          The EditorComponent is the one that used as editor.
protected  class AbstractComboBox.EnterLazyDelegateAction
           
protected  class AbstractComboBox.LazyDelegateAction
           
 class AbstractComboBox.SpinnerEditorComponent
          Default EditorComponent which has a text field.
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  StandardDialog _dialog
          The dialog that will be shown.
protected  boolean _editable
          This protected field is implementation specific.
protected  ComboBoxEditor _editor
          This protected field is implementation specific.
protected  ListDataListener _listDataListener
           
protected  Object _oldSelectedItemReminder
          This protected field is implementation specific.
protected  AbstractButton _popupButton
          The button that will show the popup.
protected  PopupPanel _popupPanel
          The actual panel inside the PopupWindow.
protected  ListCellRenderer _renderer
          This protected field is implementation specific.
protected  String actionCommand
          This protected field is implementation specific.
static String CLIENT_PROPERTY_HIDE_POPUP_ON_LIST_DATA_CHANGED
           
static String CLIENT_PROPERTY_TABLE_CELL_EDITOR
           
static String CLIENT_PROPERTY_TABLE_CELL_RENDERER
           
static int COMMIT
          Constant identifying that when focus is lost, commitEdit should be invoked.
static int COMMIT_OR_RESET
          Constant identifying that when focus is lost, commitEdit should be invoked.
static int COMMIT_OR_REVERT
          Constant identifying that when focus is lost, commitEdit should be invoked.
protected  ComboBoxModel dataModel
          This protected field is implementation specific.
static int DIALOG
          If the AbstractComboBox type is DIALOG, the popup panel will be shown as dialog.
static int DROPDOWN
          If the AbstractComboBox type is DROPDOWN, the popup panel will be shown as dropdown.
protected  Object HIDE_POPUP_KEY
           
static int PERSIST
          Constant identifying that when focus is lost, the edited value should be left.
static String PROPERTY_SELECTED_ITEM
           
static int RESET
          Constant identifying that when focus is lost, the editing value will be reset to null.
static int REVERT
          Constant identifying that when focus is lost, the editing value should be reverted to current value set on the AbstractComboBox.
protected  Object selectedItemReminder
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
AbstractComboBox()
          Creates a new DROPDOWN AbstractComboBox.
AbstractComboBox(int type)
          Creates a new AbstractComboBox with default context.
AbstractComboBox(int type, ConverterContext context)
          Creates a new AbstractComboBox.
 
Method Summary
 void actionPerformed(ActionEvent e)
          Has to make public due to implementation of an interface.
 void addActionListener(ActionListener l)
          Adds an ActionListener.
 void addItemListener(ItemListener aListener)
          Adds an ItemListener.
 void addNotify()
           
 void addPopupMenuListener(PopupMenuListener l)
          Adds a PopupMenu listener which will listen to notification messages from the popup portion of the combo box.
protected  Point calculatePopupLocation()
          calculate the popup location.
protected  boolean comboBoxSelected()
          Check if this combo box is a selected cell inside a JTable.
 boolean commitEdit()
          Commits the editing change to the AbstractComboBox.
protected  void commitEditWithFocusLostBehavior(boolean commit)
          Conditionally commit the edit considering the focusLostBehavior.
protected  void configurePropertiesFromAction(Action a)
          Factory method which sets the ActionEvent source's properties according to values from the Action instance.
protected  PropertyChangeListener createActionPropertyChangeListener(Action a)
          Factory method which creates the PropertyChangeListener used to update the ActionEvent source as properties change on its Action instance.
 AbstractButton createButtonComponent()
          Subclass should override this method to create the actual button component.
protected  AbstractButton createDefaultButton()
          Creates the default ComboBox button.
abstract  AbstractComboBox.EditorComponent createEditorComponent()
          Subclass should implement this method to create the actual editor component.
abstract  PopupPanel createPopupComponent()
          Subclass should implement this method to create the actual popup component.
protected  JidePopup createPopupWindow()
          Creates the popup window.
protected  PropertyChangeListener createPropertyChangeListener()
           
protected  JSpinner createSpinner()
          Creates the spinner for the editor component of this ComboBox.
protected  JTextField createTextField()
          Creates the text field for the editor component of this ComboBox.
protected  void customizeButton(AbstractButton button)
          Customizes the button used by the AbstractComboBox.
protected  void customizeDialog(JDialog dialog)
          Customizes the dialog.
protected  void customizeDialogLocation(JDialog dialog)
          Customizes the dialog location.
protected  void customizePopup(JidePopup popup)
          Customizes the JidePopup that is used to show the drop down.
protected  void delegateKeyStrokes()
          Delegates key strokes to popup panel.
protected  boolean equals(Object object1, Object object2)
          Check if object1 is equal to object2.
protected  void fireActionEvent()
          Notifies all listeners that have registered interest for notification on this event type without any check.
protected  void fireItemStateChanged(ItemEvent e)
          Notifies all listeners that have registered interest for notification on this event type.
 void firePopupMenuCanceled()
          Notifies PopupMenuListeners that the popup portion of the combo box has been canceled.
 void firePopupMenuWillBecomeInvisible()
          Notifies PopupMenuListeners that the popup portion of the combo box has become invisible.
 void firePopupMenuWillBecomeVisible()
          Notifies PopupMenuListeners that the popup portion of the combo box will become visible.
 void focusGained(FocusEvent e)
           
 void focusLost(FocusEvent e)
           
 AccessibleContext getAccessibleContext()
          Gets the AccessibleContext associated with this JComboBox.
 Action getAction()
          Returns the currently set Action for this ActionEvent source, or null if no Action is set.
 String getActionCommand()
          Returns the _action command that is included in the event sent to _action listeners.
 ActionListener[] getActionListeners()
          Returns an array of all the ActionListeners added to this JComboBox with addActionListener().
 Color getBackground()
           
 int getBaseline(int width, int height)
           
 ObjectConverter getConverter()
           
 ConverterContext getConverterContext()
          Gets the converter context.
protected  AbstractAction getDefaultCancelAction()
          Gets the default Cancel action for the Cancel button on the drop down panel, if needed.
protected  AbstractAction getDefaultOKAction()
          Gets the default OK action for the OK button on the drop down panel, if needed.
protected  List<KeyStroke> getDelegateKeyStrokes()
          Gets the list of KeyStrokes that will be delegated to the popup panel.
protected  JComponent getDelegateTarget()
           
protected  Action getDialogCancelAction()
          Gets the cancel button action for the dialog type ComboBox.
protected  Action getDialogOKAction()
          Gets the OK button action for the dialog type ComboBox.
 Color getDisabledBackground()
          Gets the background color when the combobox is disabled.
 Color getDisabledForeground()
          Gets the foreground color when the combobox is disabled.
 ComboBoxEditor getEditor()
          Returns the editor used to paint and edit the selected item in the JComboBox field.
 int getFocusLostBehavior()
          Returns the behavior when focus is lost.
 Color getForeground()
           
 int getHorizontalAlignment()
          Returns the horizontal alignment of the content.
 ItemListener[] getItemListeners()
          Returns an array of all the ItemListeners added to this JComboBox with addItemListener().
 ComboBoxModel getModel()
          Returns the data model currently used by the JComboBox.
 AbstractButton getPopupButton()
          Gets the button that will shows the popup.
 int getPopupCancelBehavior()
          Returns the behavior when the popup drop down is canceled.
 int getPopupLocation()
          Gets the popup location.
 PopupMenuListener[] getPopupMenuListeners()
          Returns an array of all the PopupMenuListeners added to this JComboBox with addPopupMenuListener().
 PopupPanel getPopupPanel()
          Gets the popup panel.
 int getPopupType()
          Gets the popup type.
 Object getPrototypeDisplayValue()
          Returns the "prototypical display" value - an Object used for the calculation of the display height and width.
 ListCellRenderer getRenderer()
          Returns the renderer used to display the selected item in the JComboBox field.
 Object getSelectedItem()
          Returns the current selected item.
protected  Object getSelectedItemForPopupPanel()
          Gets the selected item to setting into the popup panel before it's visible.
 Object[] getSelectedObjects()
          Returns an array containing the selected item.
 Class<?> getType()
          Gets the class of the value.
 int getVerticalAlignment()
          Returns the vertical alignment of the content.
 void hidePopup()
          Causes the combo box to close its popup window.
protected  void initComponent()
          Initialize this component such as creating button, editor etc.
protected  void initComponent(ComboBoxModel model)
          Initialize this component such as creating button, editor etc.
protected  void installColorFontAndBorder(JTable table, boolean isSelected, boolean hasFocus, int row, int column)
           
protected  void installListener()
           
 boolean isButtonOnly()
          Checks if only the button is visible.
 boolean isButtonVisible()
          Checks if the button is visible.
 boolean isClearSelectionOnListDataChanged()
          Get the flag if AbstractComboBox should clear the current selection and field if it receives list data change event.
 boolean isEditable()
          Returns true if the JComboBox is editable.
 boolean isHidePopupOnListDataChanged()
          Get the flag if AbstractComboBox should hide popup if it receives list data change event.
 boolean isKeepPopupSize()
          Checks if the popup size is kept when the popup is shown again.
 boolean isOpaque()
          Override to always return true.
 boolean isPopupVisible()
          Determines the visibility of the popup.
 boolean isPopupVolatile()
          Checks if the popup is volatile.
 boolean isStretchToFit()
          Checks if the popup panel should be stretched to be the same width as the ComboBox.
 boolean isToggleValueOnDoubleClick()
          Checks if double click on the editor part will toggle the value.
protected  boolean isUpdateFromPopupOnFly()
          This is a flag used internally.
protected  void listDataChanged()
          The action on list data change events.
protected  void modelUpdated(ComboBoxModel model)
           
 void mouseClicked(MouseEvent e)
           
 void mouseEntered(MouseEvent e)
           
 void mouseExited(MouseEvent e)
           
 void mousePressed(MouseEvent e)
           
 void mouseReleased(MouseEvent e)
           
protected  void notifyUser()
          Calls PortingUtils.notifyUser() to notify the user an error occurred when committing the edit.
protected  void paintComponent(Graphics g)
           
 void popupMenuCanceled(PopupMenuEvent e)
           
 void popupMenuWillBecomeInvisible(PopupMenuEvent e)
           
 void popupMenuWillBecomeVisible(PopupMenuEvent e)
           
protected  boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed)
           
 void removeActionListener(ActionListener l)
          Removes an ActionListener.
 void removeItemListener(ItemListener aListener)
          Removes an ItemListener.
 void removeNotify()
           
 void removePopupMenuListener(PopupMenuListener l)
          Removes a PopupMenuListener.
 void resetEdit()
          Cancels the editing change and resets to null.
 void resetPopup()
          Resets the popup.
 void revertEdit()
          Cancels the editing change and reverts to the previous valid.
protected  void selectedItemChanged()
          This protected method is implementation specific.
 void setAction(Action a)
          Sets the Action for the ActionEvent source.
 void setActionCommand(String aCommand)
          Sets the _action command that should be included in the event sent to _action listeners.
 void setBackground(Color fg)
           
 void setBorder(Border border)
           
 void setButtonOnly(boolean buttonOnly)
          Sets the visibility of the editor and only makes the button visible.
 void setButtonVisible(boolean visible)
          Sets the visibility of the button.
 void setClearSelectionOnListDataChanged(boolean clearSelectionOnListDataChanged)
          Set the flag if AbstractComboBox should clear the current selection and field if it receives list data change event.
 void setConverter(ObjectConverter converter)
           
 void setConverterContext(ConverterContext converterContext)
          Sets the converter context.
 void setDisabledBackground(Color disabledBackground)
          Sets the background color when the combobox is disabled.
 void setDisabledForeground(Color disabledForeground)
          Sets the foreground color when the combobox is disabled.
 void setEditable(boolean editable)
          Determines whether the JComboBox field is editable.
 void setEditor(ComboBoxEditor anEditor)
          Deprecated. Please do not use this method for AbstractComboBox. If you need to provide your own editor, please override createEditorComponent() method instead.
 void setEnabled(boolean enabled)
           
 void setFocusLostBehavior(int behavior)
          Sets the behavior when focus is lost.
 void setForeground(Color fg)
           
 void setHidePopupOnListDataChanged(boolean hidePopupOnListDataChanged)
          Set the flag if AbstractComboBox should hide popup if it receives list data change event.
 void setHorizontalAlignment(int alignment)
          Sets the horizontal alignment of the content.
 void setKeepPopupSize(boolean keepPopupSize)
          Sets the flag if the popup size should be kept.
 void setModel(ComboBoxModel aModel)
          Sets the data model that the JComboBox uses to obtain the list of items.
 void setPopupButton(AbstractButton button)
          Sets the popup button.
 void setPopupCancelBehavior(int behavior)
          Sets the behavior when the popup drop down is canceled.
 void setPopupType(int popupType)
          Sets the popup type.
 void setPopupVisible(boolean v)
          Sets the visibility of the popup.
 void setPopupVolatile(boolean popupVolatile)
          Sets the volatile attribute of popup.
 void setPrototypeDisplayValue(Object prototypeDisplayValue)
          Sets the prototype display value used to calculate the size of the display for the UI portion.
 void setRenderer(ListCellRenderer aRenderer)
          Sets the renderer that paints the list items and the item selected from the list in the JComboBox field.
 void setSelectedItem(Object anObject)
          Sets the selected item in the combo box display area to the object in the argument.
 void setSelectedItem(Object anObject, boolean fireEvent)
          Same as setSelectedItem(Object) except you can choose to fire the ItemEvent or not.
 void setStretchToFit(boolean stretchToFit)
          Sets the flag if the popup panel should be stretched to be the same width as the ComboBox.
 void setToggleValueOnDoubleClick(boolean toggleValueOnDoubleClick)
          Sets the flag whether the value will be toggled when double clicking on the editor part.
 void setType(Class<?> clazz)
          Sets the class of the value.
 void setVerticalAlignment(int alignment)
          Sets the vertical alignment of the content.
 void showPopup()
          Causes the combo box to display its popup window.
protected  void showPopupPanel()
          Shows the popup panel.
protected  void showPopupPanelAsPopup(boolean show)
           
protected  void undelegateKeyStrokes()
          Undelegates keystrokes.
protected  void uninstallListener()
           
protected  void updateToolTipTextForChildren()
           
 void updateUI()
           
protected  boolean validateValueForNonEditable(Object value)
           
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
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, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
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, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, 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, hide, 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, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dataModel

protected ComboBoxModel dataModel
This protected field is implementation specific. Do not access directly or override. Use the accessor methods instead.

See Also:
getModel(), setModel(javax.swing.ComboBoxModel)

_editor

protected ComboBoxEditor _editor
This protected field is implementation specific. Do not access directly or override. Use the accessor methods instead.

See Also:
getEditor(), setEditor(javax.swing.ComboBoxEditor)

_editable

protected boolean _editable
This protected field is implementation specific. Do not access directly or override. Use the accessor methods instead.

See Also:
isEditable(), setEditable(boolean)

actionCommand

protected String actionCommand
This protected field is implementation specific. Do not access directly or override. Use the accessor methods instead.

See Also:
setActionCommand(java.lang.String), getActionCommand()

_oldSelectedItemReminder

protected Object _oldSelectedItemReminder
This protected field is implementation specific. Do not access directly or override.


selectedItemReminder

protected Object selectedItemReminder

_popupButton

protected AbstractButton _popupButton
The button that will show the popup.


_dialog

protected StandardDialog _dialog
The dialog that will be shown.


_popupPanel

protected PopupPanel _popupPanel
The actual panel inside the PopupWindow.


DROPDOWN

public static final int DROPDOWN
If the AbstractComboBox type is DROPDOWN, the popup panel will be shown as dropdown.

See Also:
Constant Field Values

DIALOG

public static final int DIALOG
If the AbstractComboBox type is DIALOG, the popup panel will be shown as dialog.

See Also:
Constant Field Values

PROPERTY_SELECTED_ITEM

public static final String PROPERTY_SELECTED_ITEM
See Also:
Constant Field Values

_renderer

protected ListCellRenderer _renderer
This protected field is implementation specific. Do not access directly or override. Use the accessor methods instead.

See Also:
getRenderer(), setRenderer(javax.swing.ListCellRenderer)

CLIENT_PROPERTY_TABLE_CELL_RENDERER

public static final String CLIENT_PROPERTY_TABLE_CELL_RENDERER
See Also:
Constant Field Values

CLIENT_PROPERTY_TABLE_CELL_EDITOR

public static final String CLIENT_PROPERTY_TABLE_CELL_EDITOR
See Also:
Constant Field Values

CLIENT_PROPERTY_HIDE_POPUP_ON_LIST_DATA_CHANGED

public static final String CLIENT_PROPERTY_HIDE_POPUP_ON_LIST_DATA_CHANGED
See Also:
Constant Field Values

COMMIT

public static final int COMMIT
Constant identifying that when focus is lost, commitEdit should be invoked. If in committing the new value a ParseException is thrown, the invalid value will remain.

See Also:
setFocusLostBehavior(int), Constant Field Values

COMMIT_OR_REVERT

public static final int COMMIT_OR_REVERT
Constant identifying that when focus is lost, commitEdit should be invoked. If in committing the new value a ParseException is thrown, the value will be reverted.

See Also:
setFocusLostBehavior(int), Constant Field Values

REVERT

public static final int REVERT
Constant identifying that when focus is lost, the editing value should be reverted to current value set on the AbstractComboBox.

See Also:
setFocusLostBehavior(int), Constant Field Values

PERSIST

public static final int PERSIST
Constant identifying that when focus is lost, the edited value should be left.

See Also:
setFocusLostBehavior(int), Constant Field Values

COMMIT_OR_RESET

public static final int COMMIT_OR_RESET
Constant identifying that when focus is lost, commitEdit should be invoked. If in committing the new value a ParseException is thrown, the value will be reset to null.

See Also:
setFocusLostBehavior(int), Constant Field Values

RESET

public static final int RESET
Constant identifying that when focus is lost, the editing value will be reset to null.

See Also:
setFocusLostBehavior(int), Constant Field Values

_listDataListener

protected ListDataListener _listDataListener

HIDE_POPUP_KEY

protected Object HIDE_POPUP_KEY
Constructor Detail

AbstractComboBox

public AbstractComboBox()
Creates a new DROPDOWN AbstractComboBox.


AbstractComboBox

public AbstractComboBox(int type)
Creates a new AbstractComboBox with default context.

Parameters:
type - DIALOG or DROPDOWN

AbstractComboBox

public AbstractComboBox(int type,
                        ConverterContext context)
Creates a new AbstractComboBox.

Parameters:
type - DIALOG or DROPDOWN
context - ConverterContext
Method Detail

createEditorComponent

public abstract AbstractComboBox.EditorComponent createEditorComponent()
Subclass should implement this method to create the actual editor component.

Returns:
the editor component

createPopupComponent

public abstract PopupPanel createPopupComponent()
Subclass should implement this method to create the actual popup component.

Returns:
the popup component

createButtonComponent

public AbstractButton createButtonComponent()
Subclass should override this method to create the actual button component. If subclass doesn't implement or it returns null, a default button will be created which is the same look as the JComboBox's drop down button. There is also UIDefault "AbstractComboBox.useJButton" you can set. If it false by default. If you set it to true, we will create a JButton for it without using the JComboBox's button. If type is DROPDOWN, down arrow button will be used. If type is DIALOG, "..." button will be used.

Returns:
the button component

initComponent

protected void initComponent()
Initialize this component such as creating button, editor etc. If you choose to override this method, it'd better you override initComponent(javax.swing.ComboBoxModel) as it is guaranteed ?* to be called. this method is not called in the case of ListComboBox.


updateUI

public void updateUI()
Overrides:
updateUI in class JComponent

isPopupVolatile

public boolean isPopupVolatile()
Checks if the popup is volatile. If a popup is volatile, it will be recreated every time the popup is shown. By default, it's false. Subclasses can override it to return true or false depending on the actual case.

Returns:
true if the popup is volatile.

setPopupVolatile

public void setPopupVolatile(boolean popupVolatile)
Sets the volatile attribute of popup. If a popup is volatile, it will be recreated every time the popup is shown. By default, it's false. you can call this method to true or false depending on the actual case.

Parameters:
popupVolatile - true or false

comboBoxSelected

protected boolean comboBoxSelected()
Check if this combo box is a selected cell inside a JTable.

Returns:
true if is selected. Otherwise false.

resetPopup

public void resetPopup()
Resets the popup. If the popup is not volatile, this method will reset the popup to null so next time it will recreate again.


initComponent

protected void initComponent(ComboBoxModel model)
Initialize this component such as creating button, editor etc. All subclasses must call this method in the constructor to initialize the ComboBox.

Parameters:
model - ComboBoxModel if any. If it's null, use InfiniteComboBoxModel.

setEnabled

public void setEnabled(boolean enabled)
Overrides:
setEnabled in class JComponent

paintComponent

protected void paintComponent(Graphics g)
Overrides:
paintComponent in class JComponent

delegateKeyStrokes

protected void delegateKeyStrokes()
Delegates key strokes to popup panel. When popup panel is shown, the keyboard focus is still in the editor of ComboBox. So for certain keystrokes we need to delegate to popup panel. By default, we will delegate ESCAPE, UP, DOWN, PAGE_UP, PAGE_DOWN, ENTER, LEFT, RIGHT, HOME, and END. This method will be called when popup panel is shown and the corresponding undelegateKeyStrokes() will be called when popup panel is hidden.

Subclass can override it to delegate more. To delegate a KeyStroke, you can simply call DelegateAction.replaceAction(javax.swing.JComponent,int,javax.swing.KeyStroke,com.jidesoft.swing.DelegateAction).


undelegateKeyStrokes

protected void undelegateKeyStrokes()
Undelegates keystrokes.

Subclass can override it to undelegate those keystrokes if it overrides delegateKeyStrokes to delegate more KeyStrokes. To undelegate a KeyStroke, you can simply call DelegateAction.restoreAction(javax.swing.JComponent,int,javax.swing.KeyStroke).

See Also:
delegateKeyStrokes()

getDelegateKeyStrokes

protected List<KeyStroke> getDelegateKeyStrokes()
Gets the list of KeyStrokes that will be delegated to the popup panel. By default, we will return ESCAPE, UP, DOWN, PAGE_DOWN, PAGE_UP, ENTER, LEFT, RIGHT, HOME and END keys.

Returns:
the list of KeyStrokes that will be delegated to the popup panel.

listDataChanged

protected void listDataChanged()
The action on list data change events. You could override this method to customize your behavior.

By default, we would reset popup panel and clear selection if the flags are on.

See Also:
isHidePopupOnListDataChanged(), isClearSelectionOnListDataChanged()

getConverter

public ObjectConverter getConverter()

setConverter

public void setConverter(ObjectConverter converter)

getConverterContext

public ConverterContext getConverterContext()
Description copied from interface: ConverterContextSupport
Gets the converter context.

Specified by:
getConverterContext in interface ConverterContextSupport
Returns:
converter context

setConverterContext

public void setConverterContext(ConverterContext converterContext)
Description copied from interface: ConverterContextSupport
Sets the converter context.

Specified by:
setConverterContext in interface ConverterContextSupport
Parameters:
converterContext - converter context

getType

public Class<?> getType()
Description copied from interface: ConverterContextSupport
Gets the class of the value.

Specified by:
getType in interface ConverterContextSupport
Returns:
the class of the value.

setType

public void setType(Class<?> clazz)
Description copied from interface: ConverterContextSupport
Sets the class of the value.

Specified by:
setType in interface ConverterContextSupport

setButtonVisible

public void setButtonVisible(boolean visible)
Sets the visibility of the button. Sometimes the same CellEditor can be used as CellRenderer. If so, just set button invisible.

Parameters:
visible - true to make popup button visible.

isButtonVisible

public boolean isButtonVisible()
Checks if the button is visible.

Returns:
true if visible. Otherwise false.

setButtonOnly

public void setButtonOnly(boolean buttonOnly)
Sets the visibility of the editor and only makes the button visible. It is false by default. If you set it to true, you may also want to override createButtonComponent() to create a button that is unique, such as a date chooser icon if this is a DateComboBox. The default combobox button is not appropriate when only the button is visible.

Parameters:
buttonOnly - true to make only the popup button visible (and hide the editor area).

isButtonOnly

public boolean isButtonOnly()
Checks if only the button is visible. By default is false. You can set it to true if you just want to use a button to show the popup panel. You can listen to the item selection change to find out the new value and set it to somewhere else.

Returns:
true if visible. Otherwise false.

createPropertyChangeListener

protected PropertyChangeListener createPropertyChangeListener()

isHidePopupOnListDataChanged

public boolean isHidePopupOnListDataChanged()
Get the flag if AbstractComboBox should hide popup if it receives list data change event.

By default, the value is set to true. With this configuration, AbstractComboBox can guarantee the contents it shows up in the popup panel are the latest updated.

However, in some cases, if you want to listen to PopupMenuListener and update list data there, you have to set this flag to false. Otherwise you will get NPE thrown. Since you are updating list data while the popup menu is being shown up, you are supposed to have the full control of the list data.

Returns:
the flag if AbstractComboBox should hide popup if it receives list data change event.

setHidePopupOnListDataChanged

public void setHidePopupOnListDataChanged(boolean hidePopupOnListDataChanged)
Set the flag if AbstractComboBox should hide popup if it receives list data change event.

Parameters:
hidePopupOnListDataChanged - the flag if AbstractComboBox should hide popup if it receives list data change event.
See Also:
isHidePopupOnListDataChanged()

isClearSelectionOnListDataChanged

public boolean isClearSelectionOnListDataChanged()
Get the flag if AbstractComboBox should clear the current selection and field if it receives list data change event.

By default, the value is set to false for backward compatibility reason. You could set it to true so that AbstractComboBox can guarantee the contents it shows up in the editor field are not out-of-dated.

Returns:
the flag if AbstractComboBox should clear current selection if it receives list data change event.

setClearSelectionOnListDataChanged

public void setClearSelectionOnListDataChanged(boolean clearSelectionOnListDataChanged)
Set the flag if AbstractComboBox should clear the current selection and field if it receives list data change event.

By default, the value is set to false for backward compatibility reason. You could set it to true so that AbstractComboBox can guarantee the contents it shows up in the editor field are not out-of-dated.

Parameters:
clearSelectionOnListDataChanged - the flag if AbstractComboBox should clear current selection if it receives list data change event.
See Also:
isClearSelectionOnListDataChanged()

updateToolTipTextForChildren

protected void updateToolTipTextForChildren()

createSpinner

protected JSpinner createSpinner()
Creates the spinner for the editor component of this ComboBox. By default, it will return a JSpinner. Subclass can override it to return a JSpinner() or any other customized spinner.

Please note, JideTable has a feature to allow any key to start cell editing just like in Excel. However, in order to make this feature works in any AbstractComboBox-based cell editors, you must use AbstractComboBox.ComboBoxSpinner to replace JSpinner. So if you ever override this createSpinner to create your own JSpinner, use ComboBoxSpinner instead. The only difference between JSpinner and ComboBoxSpinner is ComboBoxSpinner implements ProcessKeyBinding interface and make processKeyBinding(...) a public method so that we can use it to pass the key event to it. Otherwise, you hit a key to start cell editing and the first key will get lost.

Returns:
the text field.

mouseClicked

public void mouseClicked(MouseEvent e)
Specified by:
mouseClicked in interface MouseListener

mousePressed

public void mousePressed(MouseEvent e)
Specified by:
mousePressed in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent e)
Specified by:
mouseReleased in interface MouseListener

mouseEntered

public void mouseEntered(MouseEvent e)
Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent e)
Specified by:
mouseExited in interface MouseListener

actionPerformed

public void actionPerformed(ActionEvent e)
Has to make public due to implementation of an interface. Do not call it directly. However you can override it if you want to provide a different action for the button. The ActionEvent will not be null if this method is triggered by the button action.

Specified by:
actionPerformed in interface ActionListener
Parameters:
e - the ActionEvent. Null if the event is actually fired by mousePressed event.

getPopupType

public int getPopupType()
Gets the popup type. It could be either DROPDOWN or DIALOG.

Returns:
the popup type.

setPopupType

public void setPopupType(int popupType)
Sets the popup type. It could be either DROPDOWN or DIALOG.

Parameters:
popupType - the new popup type.

showPopupPanel

protected void showPopupPanel()
Shows the popup panel. It will show popup as drop down or dialog depending on the type.


showPopupPanelAsPopup

protected void showPopupPanelAsPopup(boolean show)
Parameters:
show - the flag that if we should really show the popup panel

getSelectedItemForPopupPanel

protected Object getSelectedItemForPopupPanel()
Gets the selected item to setting into the popup panel before it's visible.

By default, it returns getSelectedItem() or _editor.getItem().

Returns:
the selected item.
Since:
3.5.3

customizePopup

protected void customizePopup(JidePopup popup)
Customizes the JidePopup that is used to show the drop down.

Parameters:
popup - the JidePopup.

createPopupWindow

protected JidePopup createPopupWindow()
Creates the popup window. By default it will create a JidePopup which is not detached and not resizable. Subclass can override it to create your own JidePopup or customize the default one.

Returns:
the popup window.

calculatePopupLocation

protected Point calculatePopupLocation()
calculate the popup location.

Returns:
the location of popup.

getDialogOKAction

protected Action getDialogOKAction()
Gets the OK button action for the dialog type ComboBox.

Returns:
the dialog OK action.

getDialogCancelAction

protected Action getDialogCancelAction()
Gets the cancel button action for the dialog type ComboBox.

Returns:
the dialog cancel action.

customizeDialogLocation

protected void customizeDialogLocation(JDialog dialog)
Customizes the dialog location. By default, we will call dialog.setLocationRelativeTo(null) so that it will locate at the center of the screen. If you want to put it relative to the AbstractComboBox itself, you can call dialog.setLocationRelativeTo(this). Or you can call setLocation to set it at any location on the screen. We will call this method after dialog.pack() is called and before dialog.setVisible(true) is called.

Parameters:
dialog - the dialog

customizeDialog

protected void customizeDialog(JDialog dialog)
Customizes the dialog. This method is called just before dialog.pack() and dialog.setVisible(true) are called. You can override it to add extra code to customize the dialog.

Parameters:
dialog - the dialog

getPopupButton

public AbstractButton getPopupButton()
Gets the button that will shows the popup.

Returns:
the button

setPopupButton

public void setPopupButton(AbstractButton button)
Sets the popup button.

Parameters:
button - a new popup button.

getPopupPanel

public PopupPanel getPopupPanel()
Gets the popup panel.

Returns:
the popup panel

setForeground

public void setForeground(Color fg)
Overrides:
setForeground in class JComponent

setBackground

public void setBackground(Color fg)
Overrides:
setBackground in class JComponent

getSelectedObjects

public Object[] getSelectedObjects()
Returns an array containing the selected item. This method is implemented for compatibility with ItemSelectable.

Specified by:
getSelectedObjects in interface ItemSelectable
Returns:
an array of Objects containing one element -- the selected item

fireItemStateChanged

protected void fireItemStateChanged(ItemEvent e)
Notifies all listeners that have registered interest for notification on this event type.

Parameters:
e - the event of interest
See Also:
EventListenerList

setModel

public void setModel(ComboBoxModel aModel)
Sets the data model that the JComboBox uses to obtain the list of items.

Parameters:
aModel - the ComboBoxModel that provides the displayed list of items description: Model that the combo box uses to get data to display.

getModel

public ComboBoxModel getModel()
Returns the data model currently used by the JComboBox.

Returns:
the ComboBoxModel that provides the displayed list of items

setEditable

public void setEditable(boolean editable)
Determines whether the JComboBox field is editable. An editable JComboBox allows the user to type into the field or selected an item from the list to initialize the field, after which it can be edited. (The editing affects only the field, the list item remains intact.) A non editable JComboBox displays the selected item in the field, but the selection cannot be modified.

Parameters:
editable - a boolean value, where true indicates that the field is editable preferred: true description: If true, the user can type a new value in the combo box.

isEditable

public boolean isEditable()
Returns true if the JComboBox is editable. By default, a combo box is not editable.

Returns:
true if the JComboBox is editable, else false

setEditor

@Deprecated
public void setEditor(ComboBoxEditor anEditor)
Deprecated. Please do not use this method for AbstractComboBox. If you need to provide your own editor, please override createEditorComponent() method instead.

Sets the editor used to paint and edit the selected item in the AbstractComboBox field. The editor is used only if the receiving AbstractComboBox is editable. If not editable, the combo box uses the renderer to paint the selected item.

Parameters:
anEditor - the ComboBoxEditor that displays the selected item

getEditor

public ComboBoxEditor getEditor()
Returns the editor used to paint and edit the selected item in the JComboBox field.

Returns:
the ComboBoxEditor that displays the selected item

setSelectedItem

public void setSelectedItem(Object anObject)
Sets the selected item in the combo box display area to the object in the argument. If anObject is in the list, the display area shows anObject selected.

If anObject is not in the list and the combo box is not editable, it will not change the current selection. For editable combo boxes, the selection will change to anObject.

If this constitutes a change in the selected item, ItemListeners added to the combo box will be notified with one or two ItemEvents. If there is a current selected item, an ItemEvent will be fired and the state change will be ItemEvent.DESELECTED. If anObject is in the list and is not currently selected then an ItemEvent will be fired and the state change will be ItemEvent.SELECTED.

ActionListeners added to the combo box will be notified with an ActionEvent when this method is called.

Parameters:
anObject - the list object to select; use null to clear the selection

setSelectedItem

public void setSelectedItem(Object anObject,
                            boolean fireEvent)
Same as setSelectedItem(Object) except you can choose to fire the ItemEvent or not.

Parameters:
anObject - the new value
fireEvent - true to fire event which is the same as setSelectedItem(Object). False if you don't want to fire event.

equals

protected boolean equals(Object object1,
                         Object object2)
Check if object1 is equal to object2. The default implementation is check if the object1 and object2 is the same instance. You can override it if you need more concise control on the events.

Parameters:
object1 - one of the two objects
object2 - another one of the two objects
Returns:
true if those two objects are equal. Otherwise false.

validateValueForNonEditable

protected boolean validateValueForNonEditable(Object value)

getSelectedItem

public Object getSelectedItem()
Returns the current selected item.

If the combo box is editable, then this value may not have been added to the combo box with addItem, insertItemAt or the data constructors.

Returns:
the current selected Object
See Also:
setSelectedItem(java.lang.Object)

getPrototypeDisplayValue

public Object getPrototypeDisplayValue()
Returns the "prototypical display" value - an Object used for the calculation of the display height and width.

Returns:
the value of the prototypeDisplayValue property
See Also:
setPrototypeDisplayValue(java.lang.Object)

setPrototypeDisplayValue

public void setPrototypeDisplayValue(Object prototypeDisplayValue)
Sets the prototype display value used to calculate the size of the display for the UI portion.

If a prototype display value is specified, the preferred size of the combo box is calculated by configuring the renderer with the prototype display value and obtaining its preferred size. Specifying the preferred display value is often useful when the combo box will be displaying large amounts of data. If no prototype display value has been specified, the renderer must be configured for each value from the model and its preferred size obtained, which can be relatively expensive.

Parameters:
prototypeDisplayValue - attribute: visualUpdate true description: The display prototype value, used to compute display width and height.
See Also:
getPrototypeDisplayValue()

showPopup

public void showPopup()
Causes the combo box to display its popup window.

See Also:
setPopupVisible(boolean)

hidePopup

public void hidePopup()
Causes the combo box to close its popup window.

See Also:
setPopupVisible(boolean)

setPopupVisible

public void setPopupVisible(boolean v)
Sets the visibility of the popup.

Parameters:
v - visibility

isPopupVisible

public boolean isPopupVisible()
Determines the visibility of the popup.

Returns:
true if the popup is visible, otherwise returns false

addItemListener

public void addItemListener(ItemListener aListener)
Adds an ItemListener.

aListener will receive one or two ItemEvents when the selected item changes.

Specified by:
addItemListener in interface ItemSelectable
Parameters:
aListener - the ItemListener that is to be notified
See Also:
setSelectedItem(java.lang.Object)

removeItemListener

public void removeItemListener(ItemListener aListener)
Removes an ItemListener.

Specified by:
removeItemListener in interface ItemSelectable
Parameters:
aListener - the ItemListener to remove

getItemListeners

public ItemListener[] getItemListeners()
Returns an array of all the ItemListeners added to this JComboBox with addItemListener().

Returns:
all of the ItemListeners added or an empty array if no listeners have been added

addActionListener

public void addActionListener(ActionListener l)
Adds an ActionListener.

The ActionListener will receive an ActionEvent when a selection has been made. If the combo box is editable, then an ActionEvent will be fired when editing has stopped.

Parameters:
l - the ActionListener that is to be notified
See Also:
setSelectedItem(java.lang.Object)

removeActionListener

public void removeActionListener(ActionListener l)
Removes an ActionListener.

Parameters:
l - the ActionListener to remove

getActionListeners

public ActionListener[] getActionListeners()
Returns an array of all the ActionListeners added to this JComboBox with addActionListener().

Returns:
all of the ActionListeners added or an empty array if no listeners have been added

addPopupMenuListener

public void addPopupMenuListener(PopupMenuListener l)
Adds a PopupMenu listener which will listen to notification messages from the popup portion of the combo box.

For all standard look and feels shipped with Java 2, the popup list portion of combo box is implemented as a JPopupMenu. A custom look and feel may not implement it this way and will therefore not receive the notification.

Parameters:
l - the PopupMenuListener to add

removePopupMenuListener

public void removePopupMenuListener(PopupMenuListener l)
Removes a PopupMenuListener.

Parameters:
l - the PopupMenuListener to remove
See Also:
addPopupMenuListener(javax.swing.event.PopupMenuListener)

getPopupMenuListeners

public PopupMenuListener[] getPopupMenuListeners()
Returns an array of all the PopupMenuListeners added to this JComboBox with addPopupMenuListener().

Returns:
all of the PopupMenuListeners added or an empty array if no listeners have been added

firePopupMenuWillBecomeVisible

public void firePopupMenuWillBecomeVisible()
Notifies PopupMenuListeners that the popup portion of the combo box will become visible.

This method is public but should not be called by anything other than the UI delegate.

See Also:
addPopupMenuListener(javax.swing.event.PopupMenuListener)

firePopupMenuWillBecomeInvisible

public void firePopupMenuWillBecomeInvisible()
Notifies PopupMenuListeners that the popup portion of the combo box has become invisible.

This method is public but should not be called by anything other than the UI delegate.

See Also:
addPopupMenuListener(javax.swing.event.PopupMenuListener)

firePopupMenuCanceled

public void firePopupMenuCanceled()
Notifies PopupMenuListeners that the popup portion of the combo box has been canceled.

This method is public but should not be called by anything other than the UI delegate.

See Also:
addPopupMenuListener(javax.swing.event.PopupMenuListener)

setActionCommand

public void setActionCommand(String aCommand)
Sets the _action command that should be included in the event sent to _action listeners.

Parameters:
aCommand - a string containing the "command" that is sent to _action listeners; the same listener can then do different things depending on the command it receives

getActionCommand

public String getActionCommand()
Returns the _action command that is included in the event sent to _action listeners.

Returns:
the string containing the "command" that is sent to _action listeners.

fireActionEvent

protected void fireActionEvent()
Notifies all listeners that have registered interest for notification on this event type without any check.

See Also:
EventListenerList

selectedItemChanged

protected void selectedItemChanged()
This protected method is implementation specific. Do not access directly or override.


setAction

public void setAction(Action a)
Sets the Action for the ActionEvent source. The new Action replaces any previously set Action but does not affect ActionListeners independently added with addActionListener. If the Action is already a registered ActionListener for the ActionEvent source, it is not re-registered.

A side-effect of setting the Action is that the ActionEvent source's properties are immediately set from the values in the Action (performed by the method configurePropertiesFromAction) and subsequently updated as the Action's properties change (via a PropertyChangeListener created by the method createActionPropertyChangeListener.

Parameters:
a - the Action for the JComboBox, or null. attribute: visualUpdate true description: the Action instance connected with this ActionEvent source
See Also:
Action, getAction(), configurePropertiesFromAction(javax.swing.Action), createActionPropertyChangeListener(javax.swing.Action)

getAction

public Action getAction()
Returns the currently set Action for this ActionEvent source, or null if no Action is set.

Returns:
the Action for this ActionEvent source; or null
See Also:
Action, setAction(javax.swing.Action)

configurePropertiesFromAction

protected void configurePropertiesFromAction(Action a)
Factory method which sets the ActionEvent source's properties according to values from the Action instance. The properties which are set may differ for subclasses. By default, the properties which get set are Enabled and ToolTipText.

Parameters:
a - the Action from which to get the properties, or null
See Also:
Action, setAction(javax.swing.Action)

createActionPropertyChangeListener

protected PropertyChangeListener createActionPropertyChangeListener(Action a)
Factory method which creates the PropertyChangeListener used to update the ActionEvent source as properties change on its Action instance. Subclasses may override this in order to provide their own PropertyChangeListener if the set of properties which should be kept up to date differs from the default properties (Text, Icon, Enabled, ToolTipText).

Note that PropertyChangeListeners should avoid holding strong references to the ActionEvent source, as this may hinder garbage collection of the ActionEvent source and all components in its containment hierarchy.

Parameters:
a - the action
Returns:
property change listener

popupMenuWillBecomeVisible

public void popupMenuWillBecomeVisible(PopupMenuEvent e)
Specified by:
popupMenuWillBecomeVisible in interface PopupMenuListener

popupMenuWillBecomeInvisible

public void popupMenuWillBecomeInvisible(PopupMenuEvent e)
Specified by:
popupMenuWillBecomeInvisible in interface PopupMenuListener

popupMenuCanceled

public void popupMenuCanceled(PopupMenuEvent e)
Specified by:
popupMenuCanceled in interface PopupMenuListener

focusGained

public void focusGained(FocusEvent e)
Specified by:
focusGained in interface FocusListener

focusLost

public void focusLost(FocusEvent e)
Specified by:
focusLost in interface FocusListener

commitEditWithFocusLostBehavior

protected void commitEditWithFocusLostBehavior(boolean commit)
Conditionally commit the edit considering the focusLostBehavior.

Parameters:
commit - true or false.

notifyUser

protected void notifyUser()
Calls PortingUtils.notifyUser() to notify the user an error occurred when committing the edit.


commitEdit

public boolean commitEdit()
Commits the editing change to the AbstractComboBox.

Returns:
true if commits successful. Otherwise it will return false.

revertEdit

public void revertEdit()
Cancels the editing change and reverts to the previous valid.


resetEdit

public void resetEdit()
Cancels the editing change and resets to null.


getAccessibleContext

public AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this JComboBox. For combo boxes, the AccessibleContext takes the form of an AccessibleJComboBox. A new AccessibleJComboBox instance is created if necessary.

Specified by:
getAccessibleContext in interface Accessible
Overrides:
getAccessibleContext in class JComponent
Returns:
an AccessibleJComboBox that serves as the AccessibleContext of this JComboBox

installListener

protected void installListener()

uninstallListener

protected void uninstallListener()

createDefaultButton

protected AbstractButton createDefaultButton()
Creates the default ComboBox button. This method is used only if createButtonComponent() returns null. The idea is each ComboBox can implement createButtonComponent() to provide its own button. However the default implementation should still be the button created by this method.

Returns:
the default ComboBox button.

customizeButton

protected void customizeButton(AbstractButton button)
Customizes the button used by the AbstractComboBox.

Parameters:
button - the button component.

removeNotify

public void removeNotify()
Overrides:
removeNotify in class JComponent

addNotify

public void addNotify()
Overrides:
addNotify in class JComponent

getDelegateTarget

protected JComponent getDelegateTarget()

createTextField

protected JTextField createTextField()
Creates the text field for the editor component of this ComboBox. By default, it will return a JTextField. Subclass can override it to return a JFormattedTextField() or any other customized text field.

Please note, JideTable has a feature to allow any key to start cell editing just like in Excel. However, in order to make this feature works in any AbstractComboBox-based cell editors, you must use AbstractComboBox.ComboBoxTextField to replace JTextField. So if you ever override this createTextField to create your own JTextField, use ComboBoxTextField instead. The only difference between JTextField and ComboBoxTextField is ComboBoxTextField implements ProcessKeyBinding interface and make processKeyBinding(...) a public method so that we can use it to pass the key event to it. Otherwise, you hit a key to start cell editing and the first key will get lost.

Returns:
the text field.

isOpaque

public boolean isOpaque()
Override to always return true.

Overrides:
isOpaque in class JComponent

installColorFontAndBorder

protected void installColorFontAndBorder(JTable table,
                                         boolean isSelected,
                                         boolean hasFocus,
                                         int row,
                                         int column)

setRenderer

public void setRenderer(ListCellRenderer aRenderer)
Sets the renderer that paints the list items and the item selected from the list in the JComboBox field. The renderer is used if the JComboBox is not editable. If it is editable, the editor is used to render and edit the selected item.

The default renderer displays a string or an icon. Other renderers can handle graphic images and composite items.

To display the selected item, aRenderer.getListCellRendererComponent is called, passing the list object and an index of -1.

Parameters:
aRenderer - the ListCellRenderer that displays the selected item expert: true description: The renderer that paints the item selected in the list.
See Also:
setEditor(javax.swing.ComboBoxEditor)

getRenderer

public ListCellRenderer getRenderer()
Returns the renderer used to display the selected item in the JComboBox field.

Returns:
the ListCellRenderer that displays the selected item.

getPopupLocation

public int getPopupLocation()
Gets the popup location. The ComboBox could show popup above the ComboBox or below the ComboBox depending on if there is enough space to show the whole popup.

Returns:
SwingConstants.TOP or SwingContants.BOTTOM. Usually it will return BOTTOM. But if there isn't enough space below the ComboBox to show the whole popup, the popup will show above the ComboBox. If so, it will return TOP.

processKeyBinding

protected boolean processKeyBinding(KeyStroke ks,
                                    KeyEvent e,
                                    int condition,
                                    boolean pressed)
Overrides:
processKeyBinding in class JComponent

getBaseline

public int getBaseline(int width,
                       int height)
Overrides:
getBaseline in class JComponent

setFocusLostBehavior

public void setFocusLostBehavior(int behavior)
Sets the behavior when focus is lost. This will be one of AbstractComboBox.COMMIT, AbstractComboBox.COMMIT_OR_REVERT, AbstractComboBox.REVERT, AbstractComboBox.PERSIST, AbstractComboBox.COMMIT_OR_RESET or AbstractComboBox.RESET. Note that some ObjectConverters may push changes as they occur, so that the value of this will have no effect.

This will throw an IllegalArgumentException if the object passed in is not one of the afore mentioned values.

The default value of this property is AbstractComboBox.COMMIT_OR_REVERT.

Parameters:
behavior - Identifies behavior when focus is lost
Throws:
IllegalArgumentException - if behavior is not one of the known values

getFocusLostBehavior

public int getFocusLostBehavior()
Returns the behavior when focus is lost. This will be one of COMMIT, COMMIT_OR_REVERT, REVERT, PERSIST, COMMIT_OR_RESET or RESET. Note that some ObjectConverters may push changes as they occur, so that the value of this will have no effect.

Returns:
returns behavior when focus is lost

setPopupCancelBehavior

public void setPopupCancelBehavior(int behavior)
Sets the behavior when the popup drop down is canceled. This will be one of AbstractComboBox.PERSIST, AbstractComboBox.REVERT, or AbstractComboBox.RESET.

The default value of this property is AbstractComboBox.REVERT which means the value will be reset to the previous value before the drop down is shown.

Parameters:
behavior - Identifies behavior when the drop down popup is canceled.
Throws:
IllegalArgumentException - if behavior is not one of the known values

getPopupCancelBehavior

public int getPopupCancelBehavior()
Returns the behavior when the popup drop down is canceled. This will be one of PERSIST, REVERT, or RESET.

Returns:
returns behavior when the drop down popup is canceled.

modelUpdated

protected void modelUpdated(ComboBoxModel model)

isToggleValueOnDoubleClick

public boolean isToggleValueOnDoubleClick()
Checks if double click on the editor part will toggle the value.

Returns:
true or false.

setToggleValueOnDoubleClick

public void setToggleValueOnDoubleClick(boolean toggleValueOnDoubleClick)
Sets the flag whether the value will be toggled when double clicking on the editor part. By default, it is true. Only ListComboBox and TableComboBox use this flag.

Parameters:
toggleValueOnDoubleClick - the flag

setHorizontalAlignment

public void setHorizontalAlignment(int alignment)
Description copied from interface: AlignmentSupport
Sets the horizontal alignment of the content. AbstractButton's default is SwingConstants.CENTER, but subclasses such as JCheckBox may use a different default.

Specified by:
setHorizontalAlignment in interface AlignmentSupport
Parameters:
alignment - the alignment value, one of the following values:
  • SwingConstants.RIGHT
  • SwingConstants.LEFT
  • SwingConstants.CENTER
  • SwingConstants.LEADING
  • SwingConstants.TRAILING

getHorizontalAlignment

public int getHorizontalAlignment()
Description copied from interface: AlignmentSupport
Returns the horizontal alignment of the content. AbstractButton's default is SwingConstants.CENTER, but subclasses such as JCheckBox may use a different default.

Specified by:
getHorizontalAlignment in interface AlignmentSupport
Returns:
the horizontalAlignment property, one of the following values:
  • SwingConstants.RIGHT
  • SwingConstants.LEFT
  • SwingConstants.CENTER
  • SwingConstants.LEADING
  • SwingConstants.TRAILING

getVerticalAlignment

public int getVerticalAlignment()
Description copied from interface: AlignmentSupport
Returns the vertical alignment of the content.

Specified by:
getVerticalAlignment in interface AlignmentSupport
Returns:
the verticalAlignment property, one of the following values:
  • SwingConstants.CENTER (the default)
  • SwingConstants.TOP
  • SwingConstants.BOTTOM

setVerticalAlignment

public void setVerticalAlignment(int alignment)
Description copied from interface: AlignmentSupport
Sets the vertical alignment of the content.

Specified by:
setVerticalAlignment in interface AlignmentSupport
Parameters:
alignment - one of the following values:
  • SwingConstants.CENTER (the default)
  • SwingConstants.TOP
  • SwingConstants.BOTTOM

setBorder

public void setBorder(Border border)
Overrides:
setBorder in class JComponent

isStretchToFit

public boolean isStretchToFit()
Checks if the popup panel should be stretched to be the same width as the ComboBox. By default, if this is a ListComboBox, TableComboBox or TreeComboBox, this is default to true. For ColorComboBox, DateComboBox etc, it is false by default.

Returns:
true or false.

setStretchToFit

public void setStretchToFit(boolean stretchToFit)
Sets the flag if the popup panel should be stretched to be the same width as the ComboBox. By default, if this is a ListComboBox, TableComboBox or TreeComboBox, this is default to true. For ColorComboBox, DateComboBox etc, it is false by default.

Parameters:
stretchToFit - true or false.

getDefaultOKAction

protected AbstractAction getDefaultOKAction()
Gets the default OK action for the OK button on the drop down panel, if needed. You can use this method when creating the PopupPanel such as new FontChooserPanel(getDefaultOKAction(), getDefaultCancelAction()) in createPopupComponent() method of the FontComboBox.

Returns:
the default OK action for the OK button on the drop down panel, if needed.

getDefaultCancelAction

protected AbstractAction getDefaultCancelAction()
Gets the default Cancel action for the Cancel button on the drop down panel, if needed. You can use this method when creating the PopupPanel such as new FontChooserPanel(getDefaultOKAction(), getDefaultCancelAction()) in createPopupComponent() method of the FontComboBox.

Returns:
the default Cancel action for the Cancel button on the drop down panel, if needed.

isUpdateFromPopupOnFly

protected boolean isUpdateFromPopupOnFly()
This is a flag used internally. Subclass can override it to return true or false. If true, it tells the AbstractComboBox that the change on the popup panel will automatically change the editor. Otherwise it is false.

Returns:
true or false.

getDisabledBackground

public Color getDisabledBackground()
Gets the background color when the combobox is disabled.

Returns:
the background color when the combobox is disabled.

setDisabledBackground

public void setDisabledBackground(Color disabledBackground)
Sets the background color when the combobox is disabled.

Parameters:
disabledBackground - the background color when the combobox is disabled.

getDisabledForeground

public Color getDisabledForeground()
Gets the foreground color when the combobox is disabled.

Returns:
the foreground color when the combobox is disabled.

setDisabledForeground

public void setDisabledForeground(Color disabledForeground)
Sets the foreground color when the combobox is disabled.

Parameters:
disabledForeground - the foreground color when the combobox is disabled.

getBackground

public Color getBackground()
Overrides:
getBackground in class Component

getForeground

public Color getForeground()
Overrides:
getForeground in class Component

isKeepPopupSize

public boolean isKeepPopupSize()
Checks if the popup size is kept when the popup is shown again. By default, the popup size is already reset to the popup's preferred size. However in some AbstractComboBoxes, user can resize the popup. This flag will control if the popup keeps the size after user resizes.

Returns:
true or false.

setKeepPopupSize

public void setKeepPopupSize(boolean keepPopupSize)
Sets the flag if the popup size should be kept.

Parameters:
keepPopupSize - true or false.

JIDE 3.5.15