|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JPanel com.jidesoft.combobox.PopupPanel com.jidesoft.combobox.ColorChooserPanel
public class ColorChooserPanel
ColorChooserPanel is a panel that has many color buttons. User can click on one and select the color. It supports
ItemListener. Whenever a color is selected, itemStateChanged will be fired.
We support several color sets. From
the 15 basic colors, 40 basic colors and 215 web colors. In additional to color sets, we also support gray scale,
from 16 gray scales, 102 gray scales and 256 gray scales.
Nested Class Summary | |
---|---|
class |
ColorChooserPanel.ColorButton
This class is the color button used in the ColorChooserPanel . |
static interface |
ColorChooserPanel.ColorChooserDialogProvider
An interface to bring up a custom ColorChooserDialog to choose a color when when the "More" button is pressed on the ColorChooserPanel. |
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
JPanel.AccessibleJPanel |
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 JPanel |
_colorPanel
JPanel which holds all color buttons. |
protected AbstractButton |
_defaultColor
Button for default color. |
protected AbstractButton |
_moreColor
Button for more color. |
static int |
PALETTE_COLOR_15
15 color palette. |
static int |
PALETTE_COLOR_216
Standard web-safe 216 color palette. |
static int |
PALETTE_COLOR_40
40 color palette. |
static int |
PALETTE_CUSTOMIZE
By passing value as palette, you can call setPossibleColors() and setPossibleColorNames() to setup your own palette. |
static int |
PALETTE_GRAY_102
102 gray color palette. |
static int |
PALETTE_GRAY_16
16 gray color palette. |
static int |
PALETTE_GRAY_256
256 gray color palette. |
static String |
PROPERTY_SELECTED_COLOR
|
Fields inherited from class com.jidesoft.combobox.PopupPanel |
---|
_previousSelectedObject, SELECTED_BY_MOUSE_ROLLOVER |
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 | |
---|---|
ColorChooserPanel()
Creates a new ColorChooserPanel . |
|
ColorChooserPanel(Color[] colors,
String[] names,
boolean allowMoreColors,
boolean allowDefaultColor)
Creates a new ColorChooserPanel with customized palette. |
|
ColorChooserPanel(Color[] colors,
String[] names,
boolean allowMoreColors,
boolean allowDefaultColor,
Locale locale)
Creates a new ColorChooserPanel with customized palette. |
|
ColorChooserPanel(Color[] colors,
String[] names,
int rows,
int columns,
boolean allowMoreColors,
boolean allowDefaultColor,
Locale locale)
Creates a new ColorChooserPanel with customized palette. |
|
ColorChooserPanel(int palette)
Creates a new ColorChooserPanel with specified palette. |
|
ColorChooserPanel(int palette,
boolean allowMoreColors,
boolean allowDefaultColor)
Creates a new ColorChooserPanel with the specified palette and button options. |
|
ColorChooserPanel(int palette,
boolean allowMoreColors,
boolean allowDefaultColor,
Locale locale)
Creates a new ColorChooserPanel with the specified palette and button options. |
Method Summary | |
---|---|
protected AbstractButton |
createButton(String resourceString)
|
protected void |
firstCell()
|
ColorChooserPanel.ColorButton[] |
getColorButtons()
Get the color buttons in the color chooser panel. |
ColorChooserPanel.ColorChooserDialogProvider |
getColorChooserDialogProvider()
Gets a provider that can show a ColorChooserDialog and select a color. |
protected static Color[] |
getPaletteGrayScale120()
|
protected static Color[] |
getPaletteGrayScale16()
|
protected static Color[] |
getPaletteGrayScale256()
|
Color[] |
getPossibleColors()
Gets possible colors used by this color chooser panel. |
String[] |
getPossibleColorsName()
Gets possible color names. |
protected String |
getResourceString(String key)
Gets the localized string from resource bundle. |
protected String |
getResourceString(String key,
Locale locale)
Gets the localized string from resource bundle of specified locale. |
Color |
getSelectedColor()
Gets the selected color. |
protected void |
initColors()
|
protected void |
initComponent()
|
void |
itemStateChanged(ItemEvent e)
|
protected void |
lastCell()
|
protected void |
nextCell()
|
protected void |
nextRow()
|
protected void |
prevCell()
|
protected void |
prevRow()
|
protected void |
registerKeyStrokes()
|
void |
setColorChooserDialogProvider(ColorChooserPanel.ColorChooserDialogProvider colorChooserDialogProvider)
Sets a ColorChooserDialogProvider. |
void |
setLocale(Locale locale)
|
void |
setSelectedColor(Color selectedColor)
Sets the selected color. |
protected Color |
showColorChooser(Component component,
String title,
Color initColor)
This method is called when when the "More" button is pressed on the ColorChooserPanel. |
static Color |
showColorChooserDialog(Component component,
String title,
Color initialColor)
Shows a modal color-chooser dialog and blocks until the dialog is hidden. |
void |
updateUI()
|
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int PALETTE_COLOR_15
public static final int PALETTE_COLOR_40
public static final int PALETTE_COLOR_216
public static final int PALETTE_GRAY_16
public static final int PALETTE_GRAY_102
public static final int PALETTE_GRAY_256
public static final int PALETTE_CUSTOMIZE
protected AbstractButton _defaultColor
protected AbstractButton _moreColor
protected JPanel _colorPanel
public static final String PROPERTY_SELECTED_COLOR
Constructor Detail |
---|
public ColorChooserPanel()
ColorChooserPanel
.
public ColorChooserPanel(int palette)
ColorChooserPanel
with specified palette.
palette
- the palette.public ColorChooserPanel(int palette, boolean allowMoreColors, boolean allowDefaultColor)
ColorChooserPanel
with the specified palette and button options.
palette
- color paletteallowMoreColors
- if more color button is visible.allowDefaultColor
- if default color button is visible.public ColorChooserPanel(int palette, boolean allowMoreColors, boolean allowDefaultColor, Locale locale)
ColorChooserPanel
with the specified palette and button options.
palette
- color paletteallowMoreColors
- if more color button is visible.allowDefaultColor
- if default color button is visible.locale
- the Localepublic ColorChooserPanel(Color[] colors, String[] names, boolean allowMoreColors, boolean allowDefaultColor)
ColorChooserPanel
with customized palette.
colors
- possible colorsnames
- names of possible colors.allowMoreColors
- if more color button is visible.allowDefaultColor
- if default color button is visible.public ColorChooserPanel(Color[] colors, String[] names, boolean allowMoreColors, boolean allowDefaultColor, Locale locale)
ColorChooserPanel
with customized palette.
colors
- possible colorsnames
- names of possible colors.allowMoreColors
- if more color button is visible.allowDefaultColor
- if default color button is visible.locale
- the Localepublic ColorChooserPanel(Color[] colors, String[] names, int rows, int columns, boolean allowMoreColors, boolean allowDefaultColor, Locale locale)
ColorChooserPanel
with customized palette. You can also specify how the color buttons
are laid out by passing in rows and columns. Please note, if either the rows or columns is 0, we will suggest a
preferred row and column value based on the length of the colors array. Otherwise we will use the row value
specified in the rows parameter. The value in the columns is ignored because the length of the colors and rows
are enough to determine the layout of the color labels.
Please make sure the length of colors and names array should equal with each other and not equal with 0. And
please make rows no larger than the length of colors. Otherwise, the method will throw illegal argument
exceptions.
colors
- the possible colorsnames
- the names of possible colors.rows
- the number of rows, 0 if you want to use the suggested row value based on the number of
the possible colorscolumns
- the number of columns, 0 if you want to use the suggested column value based on the
number of the possible colorsallowMoreColors
- if more color button is visible.allowDefaultColor
- if default color button is visible.locale
- the LocaleMethod Detail |
---|
public void updateUI()
updateUI
in class JPanel
protected void initColors()
protected static Color[] getPaletteGrayScale16()
protected static Color[] getPaletteGrayScale120()
protected static Color[] getPaletteGrayScale256()
public Color[] getPossibleColors()
public String[] getPossibleColorsName()
public Color getSelectedColor()
public void setSelectedColor(Color selectedColor)
selectedColor
- the selected color.protected void initComponent()
protected AbstractButton createButton(String resourceString)
protected Color showColorChooser(Component component, String title, Color initColor)
component
- the owner of the JColorChooser.title
- the title of the JColorChooser dialog.initColor
- the initial color.
public ColorChooserPanel.ColorChooserDialogProvider getColorChooserDialogProvider()
public void setColorChooserDialogProvider(ColorChooserPanel.ColorChooserDialogProvider colorChooserDialogProvider)
colorChooserDialogProvider
- a new ColorChooserDialogProvider.public ColorChooserPanel.ColorButton[] getColorButtons()
public static Color showColorChooserDialog(Component component, String title, Color initialColor) throws HeadlessException
null
.
component
- the parent Component
for the dialogtitle
- the String containing the dialog's titleinitialColor
- the initial Color set when the color-chooser is shown
null
if the user opted out
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true.GraphicsEnvironment.isHeadless()
public void itemStateChanged(ItemEvent e)
itemStateChanged
in interface ItemListener
protected void prevCell()
protected void nextCell()
protected void prevRow()
protected void nextRow()
protected void firstCell()
protected void lastCell()
protected void registerKeyStrokes()
public void setLocale(Locale locale)
setLocale
in class Component
protected String getResourceString(String key)
key
- the resource key
protected String getResourceString(String key, Locale locale)
key
- the resource keylocale
- the locale
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |