JIDE 3.5.15

com.jidesoft.combobox
Class ExComboBox

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JComboBox
                  extended by com.jidesoft.combobox.ExComboBox
All Implemented Interfaces:
ConverterContextSupport, ActionListener, ImageObserver, ItemSelectable, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible, ListDataListener
Direct Known Subclasses:
AbstractFileExComboBox, ColorExComboBox, DateExComboBox, FolderChooserExComboBox, FolderNameChooserExComboBox, FontExComboBox, InsetsExComboBox, ListExComboBox, MultilineStringExComboBox, MultiSelectListExComboBox, StringArrayExComboBox, TableExComboBox, TreeExComboBox

public abstract class ExComboBox
extends JComboBox
implements ConverterContextSupport, PropertyChangeListener

This class provides an extended version of JComboBox. It can

See Also:
Serialized Form

Nested Class Summary
protected  class ExComboBox.LazyDelegateAction
           
 
Nested classes/interfaces inherited from class javax.swing.JComboBox
JComboBox.AccessibleJComboBox, JComboBox.KeySelectionManager
 
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
static String CLIENT_PROPERTY_HIDE_POPUP_ON_LIST_DATA_CHANGED
           
static String CLIENT_PROPERTY_POPUP_PANEL
           
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.
static int DIALOG
          If the ExComboBox type is DIALOG, the popup panel will be shown as dialog.
static int DOWN_KEY_BEHAVIOR_SELECT_NEXT
          Constant identifying that pressing down key on a non-editable ExComboBox will select next possible value like plain JComboBox does by default.
static int DOWN_KEY_BEHAVIOR_SHOW_POPUP
          Constant identifying that pressing down key on a non-editable ExComboBox will show popup.
static int DROPDOWN
          If the ExComboBox type is DROPDOWN, the popup panel will be shown as dropdown.
static int PERSIST
          Constant identifying that when focus is lost, the edited value should be left.
static String PROPERTY_BUTTON_VISIBLE
           
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 ExComboBox.
 
Fields inherited from class javax.swing.JComboBox
actionCommand, dataModel, editor, isEditable, keySelectionManager, lightWeightPopupEnabled, maximumRowCount, renderer, 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
ExComboBox()
           
ExComboBox(ComboBoxModel aModel)
           
ExComboBox(int type)
          Creates a new ExComboBox with default context.
ExComboBox(int type, ConverterContext context)
          Creates a new ExComboBox.
ExComboBox(Object[] items)
           
ExComboBox(Vector<?> items)
           
 
Method Summary
protected  boolean comboBoxSelected()
          Check if this combo box is a selected cell inside a JTable.
 boolean commitEdit()
          Commits the editing change to the ExComboBox.
 void commitEditWithFocusLostBehavior(boolean commit)
          Conditionally commit the edit considering the focusLostBehavior.
 String convertElementToString(Object value)
           
 String convertElementToString(Object value, Class clazz)
           
 Object convertStringToElement(String text)
           
 Object convertStringToElement(String text, Class clazz)
           
 AbstractButton createButtonComponent()
          Subclass should override this method to create the actual button component.
abstract  PopupPanel createPopupComponent()
          Subclass should implement this method to create the actual popup component.
 void customizeDialog(JDialog dialog)
          Customizes the dialog.
 void customizeDialogLocation(JDialog dialog)
          Customizes the dialog location.
 void customizePopup(JidePopup popup, PopupPanel panel)
          Customizes the popup and the popup panel before actually showing them.
 void customizeRendererComponent(Component rendererComponent, Object value, int index, boolean selected, boolean cellHasFocus)
           
 void delegateKeyStrokes()
          Delegates key strokes to popup panel.
protected  boolean equals(Object object1, Object object2)
          Check if object1 is equal to object2.
 void fireActionEvent()
           
protected  void fireItemStateChanged(ItemEvent e)
           
 String getActualUIClassID()
           
 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.
 List<KeyStroke> getDelegateKeyStrokes()
          Gets the list of KeyStrokes that will be delegated to the popup panel.
protected  JComponent getDelegateTarget(PopupPanel panel)
           
 Action getDialogCancelAction()
          Gets the cancel button action for the dialog type ComboBox.
 Action getDialogOKAction()
          Gets the OK button action for the dialog type ComboBox.
 int getDownKeyBehavior()
          Gets the behavior when pressing down key on a non-editable ExComboBox.
 int getFocusLostBehavior()
          Returns the behavior when focus is lost.
 int getPopupCancelBehavior()
          Returns the behavior when the popup drop down is canceled.
 int getPopupLocation()
          Gets the popup location.
 int getPopupType()
          Gets the popup type.
 Object getSelectedItem()
          Returns the current selected item.
 Class<?> getType()
          Gets the class of the value.
 String getUIComboBoxEditorClassID()
          Returns a string that specifies the name of the ComboBoxEditor class that should be created for the ExComboBox.
 String getUIComboBoxPopupClassID()
          Returns a string that specifies the name of the ComboBoxPopup class that should be created for the ExComboBox.
 String getUIComboBoxRendererClassID()
          Returns a string that specifies the name of the cell renderer class that should be created for the ExComboBox.
protected  void initComboBox()
           
protected  void installColorFontAndBorder(JTable table, boolean isSelected, boolean hasFocus, int row, int column)
           
 boolean isButtonOnly()
          Checks if only the button is visible.
 boolean isButtonVisible()
          Checks if the button is visible.
 boolean isEmptyStringNull()
          Gets the flag indicating if empty string allowed as a non-null value.
 boolean isKeepPopupSize()
          Checks if the popup size is kept when the popup is shown again.
 boolean isPopupVolatile()
          Checks if the popup is volatile.
 boolean isReallyFocusLost(FocusEvent e)
           
 boolean isRetrievingValueFromPopup()
           
 boolean isStretchToFit()
          Checks if the popup panel should be stretched to be the same width as the ComboBox.
 boolean isStretchToFitSet()
           
protected  boolean isUpdateFromPopupOnFly()
          This is a flag used internally.
protected  void notifyUser()
          Calls PortingUtils.notifyUser() to notify the user an error occurred when committing the edit.
 void popupMenuCanceled(PopupMenuEvent e)
           
 boolean processKeyBinding(KeyStroke keyStroke, KeyEvent keyEvent, int i, boolean b)
           
 void propertyChange(PropertyChangeEvent evt)
           
 void resetEdit()
          Cancels the editing change and resets to null.
 void revertEdit()
          Cancels the editing change and reverts to the previous valid.
 boolean selectWithKeyChar(char keyChar)
           
 void setButtonOnly(boolean buttonOnly)
          Sets the visibility of the editor and only makes the button visible.
 void setButtonVisible(boolean buttonVisible)
          Sets the visibility of the button.
 void setConverter(ObjectConverter converter)
           
 void setConverterContext(ConverterContext converterContext)
          Sets the converter context.
 void setDownKeyBehavior(int downKeyBehavior)
          Sets the behavior when pressing down key on a non-editable ExComboBox.
 void setEditable(boolean aFlag)
           
 void setEmptyStringNull(boolean emptyStringNull)
          Sets the flag indicating if empty string allowed as a non-null value.
 void setFocusLostBehavior(int behavior)
          Sets the behavior when focus is lost.
 void setKeepPopupSize(boolean keepPopupSize)
          Sets the flag if the popup size should be kept.
 void setModel(ComboBoxModel aModel)
           
 void setPopupCancelBehavior(int behavior)
          Sets the behavior when the popup drop down is canceled.
 void setPopupLocation(int popupLocation)
           
 void setPopupType(int popupType)
          Sets the popup type.
 void setPopupVolatile(boolean popupVolatile)
          Sets the volatile attribute of popup.
 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 setType(Class<?> clazz)
          Sets the class of the value.
 void undelegateKeyStrokes()
          Undelegates keystrokes.
 void updateUI()
           
protected  boolean validateValueForNonEditable(Object value)
           
 
Methods inherited from class javax.swing.JComboBox
actionPerformed, actionPropertyChanged, addActionListener, addItem, addItemListener, addPopupMenuListener, configureEditor, configurePropertiesFromAction, contentsChanged, createActionPropertyChangeListener, createDefaultKeySelectionManager, firePopupMenuCanceled, firePopupMenuWillBecomeInvisible, firePopupMenuWillBecomeVisible, getAccessibleContext, getAction, getActionCommand, getActionListeners, getEditor, getItemAt, getItemCount, getItemListeners, getKeySelectionManager, getMaximumRowCount, getModel, getPopupMenuListeners, getPrototypeDisplayValue, getRenderer, getSelectedIndex, getSelectedObjects, getUI, getUIClassID, hidePopup, insertItemAt, installAncestorListener, intervalAdded, intervalRemoved, isEditable, isLightWeightPopupEnabled, isPopupVisible, paramString, processKeyEvent, removeActionListener, removeAllItems, removeItem, removeItemAt, removeItemListener, removePopupMenuListener, selectedItemChanged, setAction, setActionCommand, setEditor, setEnabled, setKeySelectionManager, setLightWeightPopupEnabled, setMaximumRowCount, setPopupVisible, setPrototypeDisplayValue, setRenderer, setSelectedIndex, setUI, showPopup
 
Methods inherited from class javax.swing.JComponent
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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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
 
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, 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, 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

DROPDOWN

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

See Also:
Constant Field Values

DIALOG

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

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 ExComboBox.

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

DOWN_KEY_BEHAVIOR_SELECT_NEXT

public static final int DOWN_KEY_BEHAVIOR_SELECT_NEXT
Constant identifying that pressing down key on a non-editable ExComboBox will select next possible value like plain JComboBox does by default.

See Also:
Constant Field Values

DOWN_KEY_BEHAVIOR_SHOW_POPUP

public static final int DOWN_KEY_BEHAVIOR_SHOW_POPUP
Constant identifying that pressing down key on a non-editable ExComboBox will show popup.

See Also:
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

PROPERTY_SELECTED_ITEM

public static final String PROPERTY_SELECTED_ITEM
See Also:
Constant Field Values

PROPERTY_BUTTON_VISIBLE

public static final String PROPERTY_BUTTON_VISIBLE
See Also:
Constant Field Values

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

CLIENT_PROPERTY_POPUP_PANEL

public static final String CLIENT_PROPERTY_POPUP_PANEL
See Also:
Constant Field Values
Constructor Detail

ExComboBox

public ExComboBox()

ExComboBox

public ExComboBox(Vector<?> items)

ExComboBox

public ExComboBox(Object[] items)

ExComboBox

public ExComboBox(ComboBoxModel aModel)

ExComboBox

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

Parameters:
type - DIALOG or DROPDOWN

ExComboBox

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

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

initComboBox

protected void initComboBox()

getActualUIClassID

public String getActualUIClassID()

getUIComboBoxPopupClassID

public String getUIComboBoxPopupClassID()
Returns a string that specifies the name of the ComboBoxPopup class that should be created for the ExComboBox.

Returns:
the string "ExComboBox.comboBoxPopup"
Since:
3.1.1

getUIComboBoxEditorClassID

public String getUIComboBoxEditorClassID()
Returns a string that specifies the name of the ComboBoxEditor class that should be created for the ExComboBox.

Returns:
the string "ExComboBox.comboBoxEditor"
Since:
3.1.1

getUIComboBoxRendererClassID

public String getUIComboBoxRendererClassID()
Returns a string that specifies the name of the cell renderer class that should be created for the ExComboBox.

Returns:
the string "ExComboBox.comboBoxRenderer"
Since:
3.1.1

updateUI

public void updateUI()
Overrides:
updateUI in class JComboBox

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 that consistent to ComboBoxUI in its L&F will be created which is the same look as the JComboBox's drop down button.

Returns:
the button component

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.

Overrides:
setSelectedItem in class JComboBox
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.

setEditable

public void setEditable(boolean aFlag)
Overrides:
setEditable in class JComboBox

fireItemStateChanged

protected void fireItemStateChanged(ItemEvent e)
Overrides:
fireItemStateChanged in class JComboBox

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.

Overrides:
getSelectedItem in class JComboBox
Returns:
the current selected Object
See Also:
setSelectedItem(java.lang.Object)

getDelegateTarget

protected JComponent getDelegateTarget(PopupPanel panel)

customizeRendererComponent

public void customizeRendererComponent(Component rendererComponent,
                                       Object value,
                                       int index,
                                       boolean selected,
                                       boolean cellHasFocus)

getDownKeyBehavior

public int getDownKeyBehavior()
Gets the behavior when pressing down key on a non-editable ExComboBox.

Returns:
the down key behavior.
Since:
3.2.2
See Also:
setDownKeyBehavior(int)

setDownKeyBehavior

public void setDownKeyBehavior(int downKeyBehavior)
Sets the behavior when pressing down key on a non-editable ExComboBox.

By default, the value is DOWN_KEY_BEHAVIOR_SELECT_NEXT to be consistent with plain JComboBox. However, for some ExComboBox's like DateExComboBox, TreeExComboBox, the behavior will always be to show popup.

Parameters:
downKeyBehavior - the down key behavior
Since:
3.2.2

delegateKeyStrokes

public 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).


selectWithKeyChar

public boolean selectWithKeyChar(char keyChar)
Overrides:
selectWithKeyChar in class JComboBox

undelegateKeyStrokes

public 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

public 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.

convertElementToString

public String convertElementToString(Object value,
                                     Class clazz)

convertElementToString

public String convertElementToString(Object value)

convertStringToElement

public Object convertStringToElement(String text)

convertStringToElement

public Object convertStringToElement(String text,
                                     Class clazz)

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

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

setButtonVisible

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

Parameters:
buttonVisible - 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.

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.

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 SwingConstants.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.

setPopupLocation

public void setPopupLocation(int popupLocation)

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.

isStretchToFitSet

public boolean isStretchToFitSet()

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 ExComboBoxes, 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.

setFocusLostBehavior

public void setFocusLostBehavior(int behavior)
Sets the behavior when focus is lost. This will be one of ExComboBox.COMMIT, ExComboBox.COMMIT_OR_REVERT, ExComboBox.REVERT, ExComboBox.PERSIST, ExComboBox.COMMIT_OR_RESET or ExComboBox.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 ExComboBox.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 ExComboBox.PERSIST, ExComboBox.REVERT, or ExComboBox.RESET.

The default value of this property is ExComboBox.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.

popupMenuCanceled

public void popupMenuCanceled(PopupMenuEvent e)

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Specified by:
propertyChange in interface PropertyChangeListener

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 ExComboBox that the change on the popup panel will automatically change the editor. Otherwise it is false.

Returns:
true or false.

getDialogOKAction

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

By default, it returns an empty action. Please override this method to return an action if you want to customize the ok behavior.

Returns:
the dialog OK action.

getDialogCancelAction

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

By default, it returns an empty action. Please override this method to return an action if you want to customize the cancel behavior.

Returns:
the dialog cancel action.

isReallyFocusLost

public boolean isReallyFocusLost(FocusEvent e)

commitEditWithFocusLostBehavior

public 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.


isRetrievingValueFromPopup

public boolean isRetrievingValueFromPopup()

commitEdit

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

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

revertEdit

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


comboBoxSelected

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

Returns:
true if is selected. Otherwise false.

installColorFontAndBorder

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

resetEdit

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


processKeyBinding

public boolean processKeyBinding(KeyStroke keyStroke,
                                 KeyEvent keyEvent,
                                 int i,
                                 boolean b)
Overrides:
processKeyBinding in class JComponent

customizeDialogLocation

public 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 ExComboBox 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
Since:
3.3.6

customizeDialog

public 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
Since:
3.3.6

customizePopup

public void customizePopup(JidePopup popup,
                           PopupPanel panel)
Customizes the popup and the popup panel before actually showing them.

By default, it's an empty implementation.

Parameters:
popup - the JidePopup
panel - the popup panel
Since:
3.4.1

fireActionEvent

public void fireActionEvent()
Overrides:
fireActionEvent in class JComboBox

isEmptyStringNull

public boolean isEmptyStringNull()
Gets the flag indicating if empty string allowed as a non-null value.

Returns:
true if empty string is allowed as a valid value. Otherwise false.
See Also:
setEmptyStringNull(boolean)

setEmptyStringNull

public void setEmptyStringNull(boolean emptyStringNull)
Sets the flag indicating if empty string allowed as a non-null value.

By default this flag is false so that ExComboBox will explain string in the editor like " " as a null.

This flag takes effects only if the getType() returns String.class.

Parameters:
emptyStringNull - the flag

setModel

public void setModel(ComboBoxModel aModel)
Overrides:
setModel in class JComboBox

JIDE 3.5.15