JIDE 3.5.15

com.jidesoft.combobox
Class ColorExComboBox

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
                      extended by com.jidesoft.combobox.ColorExComboBox
All Implemented Interfaces:
ConverterContextSupport, ActionListener, ImageObserver, ItemSelectable, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible, ListDataListener

public class ColorExComboBox
extends ExComboBox
implements PropertyChangeListener

ColorExComboBox is a combobox which can be used to choose a Color.

See Also:
Serialized Form

Nested Class Summary
 class ColorExComboBox.ColorIcon
          The color label component to paint the selected color.
 
Nested classes/interfaces inherited from class com.jidesoft.combobox.ExComboBox
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
protected  ColorExComboBox.ColorIcon _colorIcon
           
static String PROPERTY_COLOR_ICON_VISIBLE
           
static String PROPERTY_COLOR_MODE
           
static String PROPERTY_COLOR_VALUE_VISIBLE
           
static String PROPERTY_SELECTED_COLOR
           
 
Fields inherited from class com.jidesoft.combobox.ExComboBox
CLIENT_PROPERTY_HIDE_POPUP_ON_LIST_DATA_CHANGED, CLIENT_PROPERTY_POPUP_PANEL, CLIENT_PROPERTY_TABLE_CELL_EDITOR, CLIENT_PROPERTY_TABLE_CELL_RENDERER, COMMIT, COMMIT_OR_RESET, COMMIT_OR_REVERT, DIALOG, DOWN_KEY_BEHAVIOR_SELECT_NEXT, DOWN_KEY_BEHAVIOR_SHOW_POPUP, DROPDOWN, PERSIST, PROPERTY_BUTTON_VISIBLE, PROPERTY_SELECTED_ITEM, RESET, REVERT
 
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
ColorExComboBox()
          Creates a new ColorComboBox using ColorChooserPanel with 40 colors.
ColorExComboBox(int palette)
          Creates a new ColorComboBox.
 
Method Summary
 PopupPanel createPopupComponent()
          Creates a ColorChooserPanel as the popup.
 void customizeRendererComponent(Component rendererComponent, Object value, int index, boolean selected, boolean cellHasFocus)
           
 int getColorMode()
          Gets the color mode of the ColorComboBox.
 Dimension getPreferredSize()
           
 Color getSelectedColor()
          Gets selected color.
 boolean isAllowDefaultColor()
          If the default color button is visible.
 boolean isAllowMoreColors()
          If the more color button is visible.
 boolean isColorIconVisible()
          Checks if the color icon is displayed.
 boolean isColorValueVisible()
          Checks if the color value is displayed.
 boolean isCrossBackGroundStyle()
          Get the flag if ColorComboBox should still draw a cross in the color label

The default value now is false.

 boolean isInvalidValueAllowed()
          Checks if the invalid value is allowed.
 void propertyChange(PropertyChangeEvent evt)
          This method is called when the color changes because of navigation keys.
 void setAllowDefaultColor(boolean allowDefaultColor)
          Sets the visibility of default color button.
 void setAllowMoreColors(boolean allowMoreColors)
          Sets the visibility of more color button.
 void setColorIconVisible(boolean colorIconVisible)
          Show or hide the color icon.
 void setColorMode(int colorMode)
          Sets the color mode of the ColorComboBox.
 void setColorValueVisible(boolean colorValueVisible)
          Show or hide the color value.
 void setCrossBackGroundStyle(boolean crossBackGroundStyle)
          Set the flag if ColorComboBox should still draw a cross in the color label

The default value now is false.

 void setInvalidValueAllowed(boolean invalidValueAllowed)
          Sets the flag if the invalid value is allowed to be entered into DateComboBox.
 void setSelectedColor(Color color)
          Sets selected color.
 void setSelectedItem(Object anObject, boolean fireEvent)
          Same as ExComboBox.setSelectedItem(Object) except you can choose to fire the ItemEvent or not.
protected  void updateColorFromEditorComponent()
           
 
Methods inherited from class com.jidesoft.combobox.ExComboBox
comboBoxSelected, commitEdit, commitEditWithFocusLostBehavior, convertElementToString, convertElementToString, convertStringToElement, convertStringToElement, createButtonComponent, customizeDialog, customizeDialogLocation, customizePopup, delegateKeyStrokes, equals, fireActionEvent, fireItemStateChanged, getActualUIClassID, getConverter, getConverterContext, getDefaultCancelAction, getDefaultOKAction, getDelegateKeyStrokes, getDelegateTarget, getDialogCancelAction, getDialogOKAction, getDownKeyBehavior, getFocusLostBehavior, getPopupCancelBehavior, getPopupLocation, getPopupType, getSelectedItem, getType, getUIComboBoxEditorClassID, getUIComboBoxPopupClassID, getUIComboBoxRendererClassID, initComboBox, installColorFontAndBorder, isButtonOnly, isButtonVisible, isEmptyStringNull, isKeepPopupSize, isPopupVolatile, isReallyFocusLost, isRetrievingValueFromPopup, isStretchToFit, isStretchToFitSet, isUpdateFromPopupOnFly, notifyUser, popupMenuCanceled, processKeyBinding, resetEdit, revertEdit, selectWithKeyChar, setButtonOnly, setButtonVisible, setConverter, setConverterContext, setDownKeyBehavior, setEditable, setEmptyStringNull, setFocusLostBehavior, setKeepPopupSize, setModel, setPopupCancelBehavior, setPopupLocation, setPopupType, setPopupVolatile, setSelectedItem, setStretchToFit, setType, undelegateKeyStrokes, updateUI, validateValueForNonEditable
 
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, 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

PROPERTY_COLOR_MODE

public static final String PROPERTY_COLOR_MODE
See Also:
Constant Field Values

PROPERTY_SELECTED_COLOR

public static final String PROPERTY_SELECTED_COLOR
See Also:
Constant Field Values

PROPERTY_COLOR_VALUE_VISIBLE

public static final String PROPERTY_COLOR_VALUE_VISIBLE
See Also:
Constant Field Values

PROPERTY_COLOR_ICON_VISIBLE

public static final String PROPERTY_COLOR_ICON_VISIBLE
See Also:
Constant Field Values

_colorIcon

protected ColorExComboBox.ColorIcon _colorIcon
Constructor Detail

ColorExComboBox

public ColorExComboBox()
Creates a new ColorComboBox using ColorChooserPanel with 40 colors.


ColorExComboBox

public ColorExComboBox(int palette)
Creates a new ColorComboBox.

Parameters:
palette - the palette
Method Detail

createPopupComponent

public PopupPanel createPopupComponent()
Creates a ColorChooserPanel as the popup. Below is the default implementation.

 ColorChooserPanel panel = new ColorChooserPanel(getColorMode(), isAllowMoreColors(), isAllowDefaultColor(),
 getLocale());
 panel.addPropertyChangeListener(ColorChooserPanel.PROPERTY_SELECTED_COLOR, this);
 

Subclass can override this method to provide your own ColorChooserPanel.

Specified by:
createPopupComponent in class ExComboBox
Returns:
a ColorChooserPanel.

propertyChange

public void propertyChange(PropertyChangeEvent evt)
This method is called when the color changes because of navigation keys.

Specified by:
propertyChange in interface PropertyChangeListener
Overrides:
propertyChange in class ExComboBox
Parameters:
evt - the PropertyChangeEvent

getColorMode

public int getColorMode()
Gets the color mode of the ColorComboBox.

Returns:
the color mode

setColorMode

public void setColorMode(int colorMode)
Sets the color mode of the ColorComboBox.

Parameters:
colorMode - the valid values for this parameter are ColorChooserPanel.PALETTE_COLOR_15, ColorChooserPanel.PALETTE_COLOR_40,ColorChooserPanel.PALETTE_COLOR_216, ColorChooserPanel.PALETTE_GRAY_16, ColorChooserPanel.PALETTE_GRAY_102, and ColorChooserPanel.PALETTE_GRAY_256. You can also use your customize color palette. In this case, it's better to override createPopupComponent() to create your own ColorChooserPanel.

isAllowDefaultColor

public boolean isAllowDefaultColor()
If the default color button is visible.

Returns:
true if the default color button is visible

setAllowDefaultColor

public void setAllowDefaultColor(boolean allowDefaultColor)
Sets the visibility of default color button.

Parameters:
allowDefaultColor - true if the default color button is visible

isAllowMoreColors

public boolean isAllowMoreColors()
If the more color button is visible.

Returns:
true if more color button is visible

setAllowMoreColors

public void setAllowMoreColors(boolean allowMoreColors)
Sets the visibility of more color button.

Parameters:
allowMoreColors - true if the more color button is visible

getSelectedColor

public Color getSelectedColor()
Gets selected color.

Returns:
the selected color

updateColorFromEditorComponent

protected void updateColorFromEditorComponent()

setSelectedColor

public void setSelectedColor(Color color)
Sets selected color.

Parameters:
color - the selected color

setSelectedItem

public void setSelectedItem(Object anObject,
                            boolean fireEvent)
                     throws IllegalArgumentException
Description copied from class: ExComboBox
Same as ExComboBox.setSelectedItem(Object) except you can choose to fire the ItemEvent or not.

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

isCrossBackGroundStyle

public boolean isCrossBackGroundStyle()
Get the flag if ColorComboBox should still draw a cross in the color label

The default value now is false. But if you want to switch back to the original UI, you can set this flag to false.

Returns:
true if you want to switch back to the original cross back ground.

setCrossBackGroundStyle

public void setCrossBackGroundStyle(boolean crossBackGroundStyle)
Set the flag if ColorComboBox should still draw a cross in the color label

The default value now is false. But if you want to switch back to the original UI, you can set this flag to false.

Parameters:
crossBackGroundStyle - true if you want to switch back to the original cross back ground

getPreferredSize

public Dimension getPreferredSize()
Overrides:
getPreferredSize in class JComponent

isColorValueVisible

public boolean isColorValueVisible()
Checks if the color value is displayed.

Returns:
true if the color value is displayed.

setColorValueVisible

public void setColorValueVisible(boolean colorValueVisible)
Show or hide the color value. The color value is the text that is displayed after the color icon.

Please note, you shouldn't call setColorValueVisible(false) and setColorIconVisible(false). If you do that, we will display both color value and color icon.

Parameters:
colorValueVisible - true if the color value is visible

isColorIconVisible

public boolean isColorIconVisible()
Checks if the color icon is displayed.

Returns:
true if the color icon is displayed.

setColorIconVisible

public void setColorIconVisible(boolean colorIconVisible)
Show or hide the color icon. The color icon is at the beginning of the ColorComboBox where a color rectangle is painted.

Please note, you shouldn't call setColorValueVisible(false) and setColorIconVisible(false). If you do that, we will display both color value and color icon.

Parameters:
colorIconVisible - true if the color value is visible

isInvalidValueAllowed

public boolean isInvalidValueAllowed()
Checks if the invalid value is allowed.

Returns:
true or false.

setInvalidValueAllowed

public void setInvalidValueAllowed(boolean invalidValueAllowed)
Sets the flag if the invalid value is allowed to be entered into DateComboBox. If false (the default value), user must type a valid date string in the correct format. Otherwise, the focus lost or after enter is pressed, the invalid value will be reset. If true, the invalid string will be kept and set to the combobox using setSelectedItem. Developer can use getSelectedItem to retrieve the value. getDate or getCalendar will still return null as the value is not valid.

Parameters:
invalidValueAllowed - true or false.

customizeRendererComponent

public void customizeRendererComponent(Component rendererComponent,
                                       Object value,
                                       int index,
                                       boolean selected,
                                       boolean cellHasFocus)
Overrides:
customizeRendererComponent in class ExComboBox

JIDE 3.5.15