|
Oracle JEWT 4.2.10 | ||||||||
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 | +--oracle.bali.ewt.painter.PaintContextComponent | +--oracle.bali.ewt.LWComponent | +--oracle.bali.ewt.chooser.color.ColorPalettePane
This class implements a simple ColorPalettePane.
This component contains a grid that displays Color objects. Users can pick a color by clicking on a cell in the grid or navigating with the keyboard.
The Colors displayed in the grid are defined in a TwoDModel that is set by setColorPalette().
Clients can get the selected color by calling getSelectedColor().
Clients can add a java.beans.PropertyChangeListener and listen for the PROPERTY_SELECTED_COLOR PropertyChangeEvent to find out when the user changes the selected color.
The custom colors are displayed below the main color palette.
Clients must also supply a model for the custom colors by calling setCustomColorPalette(). The ColorPalettePane does not try to match the horizontal size of the two color palettes. It is the responsibility of the client to make sure the two color palettes have the same number of columns.
Clients need to supply a TwoDModel of color names by calling ColorPalettePane.setColorNames(). When the currently selected color changes the label will change to the name given in this data source. It is the responsibility of the client to make sure the color model and name model match up.
If the client has supplied a custom color palette they might also wish to supply a model that contains the custom color names by calling setCustomColorNames().
A ColorChooserPane is used to edit the custom color.
Clients can add custom components to, for example, load a palette, save a palette, add rows to the custom palette, or remove rows from the custom palette.
ColorChooserPane
, Serialized FormInner 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 int |
BUTTON_CANCEL
Constant indicating that the cancel button was pressed. |
static int |
BUTTON_OK
Constant indicating that the OK button was pressed. |
static java.lang.String |
PROPERTY_COLOR_PALETTE
The PropertyName to listen for when the user changes the custom Color palette. |
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.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 | |
ColorPalettePane()
Create the color palette pane with the default palette. |
|
ColorPalettePane(TwoDModel colorPalette)
Create the color palette pane with the given palette. |
|
ColorPalettePane(TwoDModel colorPalette,
java.awt.Color selectedColor,
boolean editButtonVisible)
Create the color palette pane with the given palette, the given selected color, the given visibility of the edit button, and no custom palette. |
|
ColorPalettePane(TwoDModel colorPalette,
java.awt.Color selectedColor,
boolean editButtonVisible,
TwoDModel customPalette)
Create the color palette pane with the given palette, the given selected color, the given visibility of the edit button, and the given custom palette. |
Method Summary | |
void |
addCustomComponent(java.awt.Component component)
Add a custom Component to the layout. |
void |
addNotify()
Override to set the font of the color name label to bold |
javax.accessibility.AccessibleContext |
getAccessibleContext()
Get the AccessibleContext associated with this ColorPalettePane |
ColorChooserPane |
getColorChooserPane()
Get the ColorChooserPane that will be used to edit a custom color. |
java.lang.String |
getColorName()
Get the name of the currently selected color. |
TwoDModel |
getColorNames()
Get the model that contains the color names for the main color palette. |
TwoDModel |
getColorPalette()
Returns the model of colors that the ColorPalettePane shows. |
TwoDModel |
getCustomColorNames()
Get the model that contains the color names for the custom color palette. |
TwoDModel |
getCustomColorPalette()
Returns the model of custom colors that the ColorPalettePane shows. |
java.awt.Component |
getCustomComponent(int index)
Get the custom Component at the given zero based index. |
int |
getCustomComponentCount()
Get the number of custom Components that have been added to this pane. |
java.awt.Color |
getSelectedColor()
Returns the color that is currently selected, or null if there is no selected color. |
boolean |
isColorNameVisible()
Get if the color name label is visible. |
boolean |
isCustomColorSelected()
Returns true if the currently selected color is in the custom palette. |
boolean |
isCustomColorsVisible()
Get if the custom color grid is displayed or not. |
boolean |
isEditVisible()
Get if the edit button is visible or not. |
void |
removeCustomComponent(java.awt.Component component)
Remove a custom Component from the layout. |
void |
setColorName(java.lang.String name)
Set the name of the currently selected color. |
void |
setColorNames(TwoDModel names)
Set the model that contains the color names for the main color palette. |
void |
setColorNameVisible(boolean visible)
Set if the color name label is visible. |
void |
setColorPalette(TwoDModel colors)
Change the color palette that the ColorPalettePane uses. |
void |
setCustomColorNames(TwoDModel names)
Set the model that contains the color names for the custom color palette. |
void |
setCustomColorPalette(TwoDModel colors)
Change the custom color palette that the ColorPalettePane uses. |
void |
setCustomColorsVisible(boolean visible)
Set if the custom color grid is displayed or not. |
void |
setEditVisible(boolean visible)
Set if the edit button is visible or not. |
void |
setEnabled(boolean enabled)
Override to pass onto children. |
void |
setLocale(java.util.Locale newLocale)
Override to set strings when locale changes. |
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 the custom palette or the main palette of the color grid. |
static int |
showDialog(java.awt.Component parent,
ColorPalettePane pane)
Show the given ColorPalettePane in a modal, non resizable, Dialog with the default title, centered over the given parent component. |
static int |
showDialog(java.awt.Component parent,
ColorPalettePane pane,
java.lang.String dialogTitle,
boolean resizable)
Show the given ColorPalettePane in a modal Dialog with the given resizability, with the given title, centered over the given parent component. |
Methods inherited from class oracle.bali.ewt.LWComponent |
clipToParents, freezeRepaints, getActualAlignment, getActualReadingDirection, getAlignment, getBorderInsets, getDocumentSize, getFill, getPageBounds, getPrintPaintContext, isFocusTraversable, paintChildren, paintComponent, paintImmediateInterior, paintImmediateInterior, paintImmediately, paintOverChildren, printPage, processEvent, processEventImpl, repaint, repaintInterior, repaintInterior, setAlignment, setFill, unfreezeRepaints, updateUI |
Methods inherited from class oracle.bali.ewt.painter.PaintContextComponent |
getBorderContext, getPaintContext, getPaintData, getPaintState, getUIDefaults, setUI |
Methods inherited from class javax.swing.JComponent |
addAncestorListener, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, 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, 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, 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, imageUpdate, 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_COLOR_PALETTE
public static final java.lang.String PROPERTY_SELECTED_COLOR
public static final int BUTTON_OK
showDialog(java.awt.Component, oracle.bali.ewt.chooser.color.ColorPalettePane)
public static final int BUTTON_CANCEL
showDialog(java.awt.Component, oracle.bali.ewt.chooser.color.ColorPalettePane)
Constructor Detail |
public ColorPalettePane()
public ColorPalettePane(TwoDModel colorPalette)
public ColorPalettePane(TwoDModel colorPalette, java.awt.Color selectedColor, boolean editButtonVisible)
public ColorPalettePane(TwoDModel colorPalette, java.awt.Color selectedColor, boolean editButtonVisible, TwoDModel customPalette)
Method Detail |
public static int showDialog(java.awt.Component parent, ColorPalettePane pane)
parent
- The parent component to center the dialog over.pane
- The ColorPalettePane to show in the dialogpublic static int showDialog(java.awt.Component parent, ColorPalettePane pane, java.lang.String dialogTitle, boolean resizable)
parent
- The parent component to center the dialog over.pane
- The ColorPalettePane to show in the dialogdialogTitle
- The title of the dialogresizable
- True if the dialog is resizablepublic void setColorPalette(TwoDModel colors)
getColorPalette()
public TwoDModel getColorPalette()
setColorPalette(oracle.bali.ewt.model.TwoDModel)
public void setCustomColorPalette(TwoDModel colors)
getCustomColorPalette()
,
setCustomColorsVisible(boolean)
public TwoDModel getCustomColorPalette()
getCustomColorPalette()
public void setEditVisible(boolean visible)
isEditVisible()
public boolean isEditVisible()
setEditVisible(boolean)
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 custom 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 the color modelpublic void setColorNames(TwoDModel names)
getColorNames()
,
setColorPalette(oracle.bali.ewt.model.TwoDModel)
public TwoDModel getColorNames()
setColorNames(oracle.bali.ewt.model.TwoDModel)
public void setCustomColorNames(TwoDModel names)
getCustomColorNames()
,
setCustomColorPalette(oracle.bali.ewt.model.TwoDModel)
public TwoDModel getCustomColorNames()
setCustomColorNames(oracle.bali.ewt.model.TwoDModel)
public void setColorName(java.lang.String name)
getColorName()
,
isColorNameVisible()
,
setColorNames(oracle.bali.ewt.model.TwoDModel)
,
setCustomColorNames(oracle.bali.ewt.model.TwoDModel)
public java.lang.String getColorName()
setColorName(java.lang.String)
,
isColorNameVisible()
public void setCustomColorsVisible(boolean visible)
isCustomColorsVisible()
,
setCustomColorPalette(oracle.bali.ewt.model.TwoDModel)
public boolean isCustomColorsVisible()
setCustomColorsVisible(boolean)
public void setColorNameVisible(boolean visible)
isColorNameVisible()
public boolean isColorNameVisible()
setColorNameVisible(boolean)
public void addCustomComponent(java.awt.Component component)
removeCustomComponent(java.awt.Component)
public void removeCustomComponent(java.awt.Component component)
addCustomComponent(java.awt.Component)
public int getCustomComponentCount()
addCustomComponent(java.awt.Component)
public java.awt.Component getCustomComponent(int index)
addCustomComponent(java.awt.Component)
,
getCustomComponentCount()
public ColorChooserPane getColorChooserPane()
public void setEnabled(boolean enabled)
setEnabled
in class javax.swing.JComponent
public void addNotify()
addNotify
in class javax.swing.JComponent
public javax.accessibility.AccessibleContext getAccessibleContext()
getAccessibleContext
in interface javax.accessibility.Accessible
getAccessibleContext
in class javax.swing.JComponent
public void setLocale(java.util.Locale newLocale)
setLocale
in class java.awt.Component
|
Oracle JEWT 4.2.10 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |