|
Oracle JEWT API Reference Release 4.2.24.0.0 B12199-01 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--javax.swing.AbstractButton | +--javax.swing.JButton | +--oracle.bali.ewt.chooser.color.ColorChoice
This class implements a simple color choice. The component looks like a button, with Icons or String label, until the color grid is activated by pushing the button or using the alt-down sequence.
The ColorChoice will display a default Image in the button. This image contains an area that will automatically be changed to match the currently selected color.
Clients can call setImage(Image, Color) to set their own Image on the ColorChoice. Every pixel in the Image that matches the Color will be changed to the currently selected color every time the selected color changes.
Alternatively, clients can use the JButton methods setIcon(), setDisabledIcon(), etc. If clients change the icon or disabledIcon the ColorChoice will not be able to automatically update the image to display the currently selected color.
The ColorChoice also allows the selection of a transparent color. If isTransparentAllowed() returns true the user will be able to select a toggle button when the color grid is dropped down that corresponds to no selected color. getSelectedColor() will return null in this case.
The ColorChoice also allows users to edit the color palette. If isEditAllowed() returns true an edit button is displayed below the pop down grid that displays a ColorPalettePane. Users can then add and delete colors or replace colors in the grid. The ColorChoice will fire a PROPERTY_COLOR_PALETTE event when the user changes the palette. Alternatively, clients can add a TwoDModelListener to the TwoDModel of colors to see if it changes.
ColorChoice now supports an automatic mode. If users choose this button than the application should automatically pick the correct color. The ColorChoice will display a different icon in the button to indicate that the automatic mode is selected. Clients can display the automatic button by calling setAutomaticAllowed(). Clients can listen to changes in the state of automatic by listening for PROPERTY_AUTOMATIC_SELECTED events. When automatic is selected the selected color is set to null.
ColorChoice now supports a default color. If isDefaultAllowed() is true a button is displayed above the color palette that lets the user choose the defaultColor. The selectedColor will then become the defaultColor and a PROPERTY_DEFAULT_SELECTED event is sent.
The Oracle User Interface team has defined a set of common color palettes that can be used with the ColorChoice. Please see ColorGrid.getColorPalette(int) for a list of these common palettes.
The ColorChoice fires a PROPERTY_AUTOMATIC_SELECTED PropertyChangeEvent when the user changes automaticSelected property..
The ColorChoice fires a PROPERTY_DEFAULT_SELECTED PropertyChangeEvent when the user changes defaultSelected property..
The ColorChoice fires a PROPERTY_COLOR_PALETTE PropertyChangeEvent if the user edits the color palette displayed in the ColorChoice.
The ColorChoice fires a PROPERTY_POPUP_VISIBLE PropertyChangeEvent whenever the drop down ColorPopup is opened or closed.
TwoDModel
,
oracle.bali.ewt.color.ColorGrid
, Serialized FormInner classes inherited from class javax.swing.JButton |
javax.swing.JButton.AccessibleJButton |
Inner classes inherited from class javax.swing.AbstractButton |
javax.swing.AbstractButton.AccessibleAbstractButton, javax.swing.AbstractButton.ButtonChangeListener |
Inner classes inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent |
Inner classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
Inner classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent |
Field Summary | |
static java.lang.String |
PROPERTY_AUTOMATIC_SELECTED
The PropertyName to listen for when the user changes the value of the automatic mode in the drop down list of the ColorChoice. |
static java.lang.String |
PROPERTY_COLOR_PALETTE
The PropertyName to listen for when the user changes the custom Color Palette displayed in the drop down list of the ColorChoice. |
static java.lang.String |
PROPERTY_DEFAULT_SELECTED
The PropertyName to listen for when the user changes the chooses the default color (or chooses a color in the palette). |
static java.lang.String |
PROPERTY_POPUP_VISIBLE
The PropertyName to listen for when the drop down ColorPopup is opened or closed. |
static java.lang.String |
PROPERTY_SELECTED_COLOR
The PropertyName to listen for when the user changes the selected color. |
Fields inherited from class javax.swing.AbstractButton |
actionListener, BORDER_PAINTED_CHANGED_PROPERTY, changeEvent, changeListener, CONTENT_AREA_FILLED_CHANGED_PROPERTY, DISABLED_ICON_CHANGED_PROPERTY, DISABLED_SELECTED_ICON_CHANGED_PROPERTY, FOCUS_PAINTED_CHANGED_PROPERTY, HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, ICON_CHANGED_PROPERTY, itemListener, MARGIN_CHANGED_PROPERTY, MNEMONIC_CHANGED_PROPERTY, model, MODEL_CHANGED_PROPERTY, PRESSED_ICON_CHANGED_PROPERTY, ROLLOVER_ENABLED_CHANGED_PROPERTY, ROLLOVER_ICON_CHANGED_PROPERTY, ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, SELECTED_ICON_CHANGED_PROPERTY, TEXT_CHANGED_PROPERTY, VERTICAL_ALIGNMENT_CHANGED_PROPERTY, VERTICAL_TEXT_POSITION_CHANGED_PROPERTY |
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 javax.swing.SwingConstants |
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NORTH, NORTH_EAST, NORTH_WEST, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
ColorChoice()
Create a color choice with no label, the default icon, the default palette and no selected color. |
|
ColorChoice(javax.swing.Icon icon)
Create a color choice with the no label, the given icon, the default palette and no selected color. |
|
ColorChoice(javax.swing.Icon icon,
TwoDModel colorPalette,
java.awt.Color selectColor)
Create a ColorChoice object that look like a button with an icon label. |
|
ColorChoice(java.lang.String label)
Create a color choice with the given label, the default icon, the default palette and no selected color. |
|
ColorChoice(java.lang.String label,
TwoDModel colorPalette,
java.awt.Color selectColor)
Create a ColorChoice object that lookl like a button with a text label. |
Method Summary | |
void |
addNotify()
Overridden to update the strings used in the ColorChoice. |
void |
dispose()
Free any memory associated with this ColorChoice. |
protected void |
firePropertyChange(java.lang.String name,
java.lang.Object oldValue,
java.lang.Object newValue)
Subclass so inner classes can access. |
javax.accessibility.AccessibleContext |
getAccessibleContext()
Override to return a new AccessibleContext. |
java.awt.Color |
getClosestColor(java.awt.Color color)
Return a Color in the ColorChoice's main palette that is closest to the given color. |
java.awt.Color |
getClosestColor(java.awt.Color color,
boolean useCustomPalette)
Return a Color in the either the ColorChoice's main palette or custom palette that is closest to the given color. |
TwoDModel |
getColorPalette()
Returns the TwoDModel of colors that the ColorChoice shows. |
ColorPalettePane |
getColorPalettePane()
Get the ColorPalettePane object used to edit the color palettes. |
java.awt.Color |
getColorToChange()
Get the Color to change in the Image from getImage(). |
TwoDModel |
getCustomColorPalette()
Get the custom color palette that the ColorChoice uses. |
java.awt.Color |
getDefaultColor()
Get the default color used by the ColorChoice. |
java.awt.Image |
getImage()
Get the Image to use to create the icons in the button. |
java.awt.Color |
getSelectedColor()
Returns the color that is currently selected, or null if there is no selected color. |
boolean |
isAutomaticAllowed()
Returns true if a toggle button is displayed when the color grid is dropped down that allows users to choose the automatic option. |
boolean |
isAutomaticSelected()
Return true if the user has chosen the automatic mode. |
static boolean |
isColorInPalette(TwoDModel palette,
java.awt.Color c)
Return true if the given color is in the given palette. |
boolean |
isCustomColorSelected()
Returns true if the currently selected color is in the custom palette. |
boolean |
isDefaultAllowed()
Returns true if a button is displayed when the color grid is dropped down that allows users to choose the default color. |
boolean |
isDefaultSelected()
Return true if the user has chosen the default color. |
boolean |
isEditAllowed()
Returns true if a button is displayed when the color grid is dropped down that allows users to change the color palette shown in the ColorChoice. |
boolean |
isPopupVisible()
Returns true if the drop down color popup is currently visible. |
boolean |
isTransparentAllowed()
Returns true if a toggle button is displayed when the color grid is dropped down that allows users to choose a transparent color (no color). |
void |
removeNotify()
Overridden to take down the dropdown grid when the ColorChoice is taken out of the component hierarchy. |
void |
setAutomaticAllowed(boolean automaticAllowed)
Set if a toggle button is displayed when the color grid is dropped down that allows users to the automatic option. |
void |
setAutomaticSelected(boolean selected)
Set if the user has chosen the automatic mode. |
void |
setColorPalette(TwoDModel colorPalette)
Change the TwoDModel of colors that the ColorChoice uses. |
void |
setCustomColorPalette(TwoDModel colorPalette)
Set the custom color palette that the ColorChoice uses. |
void |
setDefaultAllowed(boolean defaultAllowed)
Set if a button is displayed when the color grid is dropped down that allows users to pick the default color. |
void |
setDefaultColor(java.awt.Color defaultColor)
Set the default color used by the ColorChoice. |
void |
setDefaultSelected(boolean selected)
Set if the user has chosen the default color. |
void |
setDisabledIcon(javax.swing.Icon icon)
Override to clear the Image. |
void |
setEditAllowed(boolean isEditAllowed)
Set if a button is displayed when the color grid is dropped down that allows users to change the color palette shown in the ColorChoice. |
void |
setIcon(javax.swing.Icon icon)
Override to clear the Image. |
void |
setImage(java.awt.Image image,
java.awt.Color colorToChange)
Set the Image used in the ColorChoice. |
void |
setLocale(java.util.Locale l)
Override to change the strings used in the ColorChoice. |
void |
setSelectedColor(java.awt.Color c)
Sets the selected color in the default grid. |
void |
setSelectedColor(java.awt.Color c,
boolean colorInCustomPalette)
Sets the selected color in the either of the models. |
void |
setTransparentAllowed(boolean transparentAllowed)
Set if a toggle button is displayed when the color grid is dropped down that allows users to choose a transparent color (no color). |
void |
updateUI()
Override to update ui of buttons |
Methods inherited from class javax.swing.JButton |
configurePropertiesFromAction, getUIClassID, isDefaultButton, isDefaultCapable, paramString, setDefaultCapable |
Methods inherited from class javax.swing.AbstractButton |
addActionListener, addChangeListener, addItemListener, checkHorizontalKey, checkVerticalKey, createActionListener, createActionPropertyChangeListener, createChangeListener, createItemListener, doClick, doClick, fireActionPerformed, fireItemStateChanged, fireStateChanged, getAction, getActionCommand, getDisabledIcon, getDisabledSelectedIcon, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getLabel, getMargin, getMnemonic, getModel, getPressedIcon, getRolloverIcon, getRolloverSelectedIcon, getSelectedIcon, getSelectedObjects, getText, getUI, getVerticalAlignment, getVerticalTextPosition, imageUpdate, init, isBorderPainted, isContentAreaFilled, isFocusPainted, isFocusTraversable, isRolloverEnabled, isSelected, paintBorder, removeActionListener, removeChangeListener, removeItemListener, setAction, setActionCommand, setBorderPainted, setContentAreaFilled, setDisabledSelectedIcon, setEnabled, setFocusPainted, setHorizontalAlignment, setHorizontalTextPosition, setLabel, setMargin, setMnemonic, setMnemonic, setModel, setPressedIcon, setRolloverEnabled, setRolloverIcon, setRolloverSelectedIcon, setSelected, setSelectedIcon, setText, setUI, setVerticalAlignment, setVerticalTextPosition |
Methods inherited from class javax.swing.JComponent |
addAncestorListener, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.lang.String PROPERTY_SELECTED_COLOR
public static final java.lang.String PROPERTY_COLOR_PALETTE
public static final java.lang.String PROPERTY_AUTOMATIC_SELECTED
public static final java.lang.String PROPERTY_DEFAULT_SELECTED
public static final java.lang.String PROPERTY_POPUP_VISIBLE
Constructor Detail |
public ColorChoice()
public ColorChoice(java.lang.String label)
public ColorChoice(javax.swing.Icon icon)
public ColorChoice(java.lang.String label, TwoDModel colorPalette, java.awt.Color selectColor)
label
- a textual label to use for the button.colorPalette
- a TwoDModel that contains Color objects.selectColor
- a color from the colorPalette parameter to initially
select.public ColorChoice(javax.swing.Icon icon, TwoDModel colorPalette, java.awt.Color selectColor)
icon
- an Icon to use for the button.colorPalette
- a TwoDModel that contains Color objects.selectColor
- a color from the colorPalette parameter to initially
select.Method Detail |
public void setIcon(javax.swing.Icon icon)
setIcon
in class javax.swing.AbstractButton
setImage(java.awt.Image, java.awt.Color)
public void setDisabledIcon(javax.swing.Icon icon)
setDisabledIcon
in class javax.swing.AbstractButton
setImage(java.awt.Image, java.awt.Color)
public void setImage(java.awt.Image image, java.awt.Color colorToChange)
image
- The base image to use as the icons for the
ColorChoicecolorToChange
- Every pixel that makes colorToChange
in image will be transformed to the
currently selected colorpublic java.awt.Image getImage()
setImage(java.awt.Image, java.awt.Color)
public java.awt.Color getColorToChange()
getImage()
,
setImage(java.awt.Image, java.awt.Color)
public void setColorPalette(TwoDModel colorPalette)
public TwoDModel getColorPalette()
public void setCustomColorPalette(TwoDModel colorPalette)
getCustomColorPalette()
,
setColorPalette(oracle.bali.ewt.model.TwoDModel)
public TwoDModel getCustomColorPalette()
setCustomColorPalette(oracle.bali.ewt.model.TwoDModel)
,
setColorPalette(oracle.bali.ewt.model.TwoDModel)
public boolean isTransparentAllowed()
setTransparentAllowed(boolean)
public void setTransparentAllowed(boolean transparentAllowed)
isTransparentAllowed()
public boolean isEditAllowed()
The default is false.
If the colorPalette is changed the ColorChoice will fire a PROPERTY_COLOR_PALETTE PropertyChangeEvent.
setEditAllowed(boolean)
public void setEditAllowed(boolean isEditAllowed)
The default is false.
If the colorPalette is changed the ColorChoice will fire a PROPERTY_COLOR_PALETTE PropertyChangeEvent.
isEditAllowed()
public boolean isAutomaticAllowed()
setAutomaticAllowed(boolean)
public void setAutomaticAllowed(boolean automaticAllowed)
isAutomaticAllowed()
public boolean isAutomaticSelected()
public void setAutomaticSelected(boolean selected)
isAutomaticSelected()
,
isAutomaticAllowed()
public boolean isDefaultAllowed()
setDefaultAllowed(boolean)
,
setDefaultColor(java.awt.Color)
public void setDefaultAllowed(boolean defaultAllowed)
isDefaultAllowed()
public void setDefaultColor(java.awt.Color defaultColor)
isDefaultAllowed()
,
getDefaultColor()
public java.awt.Color getDefaultColor()
isDefaultAllowed()
,
setDefaultColor(java.awt.Color)
public boolean isDefaultSelected()
setDefaultSelected(boolean)
,
isDefaultAllowed()
public void setDefaultSelected(boolean selected)
isDefaultSelected()
,
isDefaultAllowed()
public void setSelectedColor(java.awt.Color c)
This must be a color from the model of getColorPalette().
java.lang.IllegalArgumentException
- if the color is not
found in the color palette.public java.awt.Color getSelectedColor()
public boolean isCustomColorSelected()
public void setSelectedColor(java.awt.Color c, boolean colorInCustomPalette)
If colorInCustomPalette is false the the color must be in the getColorPalette() model. Otherwise the color must be in the getCustomColorPalette() model.
java.lang.IllegalArgumentException
- if the color is not
found in either of the color data sources.public java.awt.Color getClosestColor(java.awt.Color color)
public java.awt.Color getClosestColor(java.awt.Color color, boolean useCustomPalette)
public ColorPalettePane getColorPalettePane()
isEditAllowed()
public boolean isPopupVisible()
public static boolean isColorInPalette(TwoDModel palette, java.awt.Color c)
public void setLocale(java.util.Locale l)
setLocale
in class java.awt.Component
public void addNotify()
addNotify
in class javax.swing.JComponent
public void removeNotify()
removeNotify
in class javax.swing.JButton
public void updateUI()
updateUI
in class javax.swing.JButton
public javax.accessibility.AccessibleContext getAccessibleContext()
getAccessibleContext
in class javax.swing.JButton
public void dispose()
protected void firePropertyChange(java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)
firePropertyChange
in class javax.swing.JComponent
|
Oracle JEWT 4.2.24 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |