APIdia Launch Partner
Top Description Fields Constructors Methods
javax.swing.colorchooser

public abstract Class AbstractColorChooserPanel

extends JPanel
Class Inheritance
Known Direct Subclasses
javax.swing.colorchooser.ColorChooserPanel, javax.swing.colorchooser.DefaultSwatchChooserPanel, com.sun.java.swing.plaf.gtk.GTKColorChooserPanel
Annotations
@SuppressWarnings:serial
Imports
java.awt.*, java.beans.BeanProperty, .PropertyChangeEvent, .PropertyChangeListener, javax.swing.*

This is the abstract superclass for color choosers. If you want to add a new color chooser panel into a JColorChooser, subclass this class.

Warning

Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans has been added to the java.beans package. Please see java.beans.XMLEncoder.

Authors
Tom Santos, Steve Wilson

Field Summary

Modifier and TypeField and Description
private JColorChooser
private final PropertyChangeListener
public static final String
TRANSPARENCY_ENABLED_PROPERTY

Identifies that the transparency of the color (alpha value) can be selected

Constructor Summary

AccessConstructor and Description
protected
AbstractColorChooserPanel()

Constructor for subclasses to call.

Method Summary

Modifier and TypeMethod and Description
protected abstract void
buildChooser()

Builds a new chooser panel.

protected Color

Returns:

the Color that is selected
getColorFromModel
()

Returns the color that is currently selected.

public ColorSelectionModel

Returns:

the ColorSelectionModel model this panel is editing
getColorSelectionModel
()

Returns the model that the chooser panel is editing.

public int

Returns:

Character index to render mnemonic for; -1 to provide no visual identifier for this panel.
getDisplayedMnemonicIndex
()

Provides a hint to the look and feel as to the index of the character in getDisplayName that should be visually identified as the mnemonic.

public abstract String

Returns:

the name of the display panel
getDisplayName
()

Returns a string containing the display name of the panel.

pack-priv int

Returns:

the int
getInt
(Object
an Object specifying the int
key
,
int
Returned value if key is not available, or is not an Integer
defaultValue
)

Returns an integer from the defaults table.

public abstract Icon

Returns:

the large display icon
getLargeDisplayIcon
()

Returns the large display icon for the panel.

public int

Returns:

KeyEvent.VK constant identifying the mnemonic; <= 0 for no mnemonic
getMnemonic
()

Provides a hint to the look and feel as to the KeyEvent.VK constant that can be used as a mnemonic to access the panel.

public abstract Icon

Returns:

the small display icon
getSmallDisplayIcon
()

Returns the small display icon for the panel.

public void
installChooserPanel(JColorChooser
the chooser to which the panel is to be added
enclosingChooser
)

Invoked when the panel is added to the chooser.

public boolean

Returns:

true if the transparency of a color can be selected
isColorTransparencySelectionEnabled
()

Gets whether color chooser panel allows to select the transparency (alpha value) of a color.

public void
paint(Graphics
the Graphics object
g
)

Overrides javax.swing.JComponent.paint.

Draws the panel.

public void
setColorTransparencySelectionEnabled(boolean
true if the transparency of a color can be selected
b
)

Sets whether color chooser panel allows to select the transparency (alpha value) of a color.

pack-priv void
public void
uninstallChooserPanel(JColorChooser
the chooser from which the panel is to be removed
enclosingChooser
)

Invoked when the panel is removed from the chooser.

public abstract void
updateChooser()

Invoked automatically when the model's state changes.

Inherited from javax.swing.JPanel:
getAccessibleContextgetUIgetUIClassIDparamStringsetUIupdateUI

Field Detail

chooserback to summary
private JColorChooser chooser
enabledListenerback to summary
private final PropertyChangeListener enabledListener
TRANSPARENCY_ENABLED_PROPERTYback to summary
public static final String TRANSPARENCY_ENABLED_PROPERTY

Identifies that the transparency of the color (alpha value) can be selected

Constructor Detail

AbstractColorChooserPanelback to summary
protected AbstractColorChooserPanel()

Constructor for subclasses to call.

Method Detail

buildChooserback to summary
protected abstract void buildChooser()

Builds a new chooser panel.

getColorFromModelback to summary
protected Color getColorFromModel()

Returns the color that is currently selected.

Returns:Color

the Color that is selected

getColorSelectionModelback to summary
public ColorSelectionModel getColorSelectionModel()

Returns the model that the chooser panel is editing.

Returns:ColorSelectionModel

the ColorSelectionModel model this panel is editing

getDisplayedMnemonicIndexback to summary
public int getDisplayedMnemonicIndex()

Provides a hint to the look and feel as to the index of the character in getDisplayName that should be visually identified as the mnemonic. The look and feel should only use this if getMnemonic returns a value > 0.

The return value here is a hint, it is ultimately up to the look and feel to honor the return value in some meaningful way. For example, a look and feel may wish to render each AbstractColorChooserPanel in a JTabbedPane, and further use this return value to underline a character in the getDisplayName.

This implementation returns -1, indicating the AbstractColorChooserPanel does not support a mnemonic, subclasses wishing a mnemonic will need to override this.

Returns:int

Character index to render mnemonic for; -1 to provide no visual identifier for this panel.

Since
1.4
See Also
getMnemonic
getDisplayNameback to summary
public abstract String getDisplayName()

Returns a string containing the display name of the panel.

Returns:String

the name of the display panel

getIntback to summary
pack-priv int getInt(Object key, int defaultValue)

Returns an integer from the defaults table. If key does not map to a valid Integer, default is returned.

Parameters
key:Object

an Object specifying the int

defaultValue:int

Returned value if key is not available, or is not an Integer

Returns:int

the int

getLargeDisplayIconback to summary
public abstract Icon getLargeDisplayIcon()

Returns the large display icon for the panel.

Returns:Icon

the large display icon

getMnemonicback to summary
public int getMnemonic()

Provides a hint to the look and feel as to the KeyEvent.VK constant that can be used as a mnemonic to access the panel. A return value <= 0 indicates there is no mnemonic.

The return value here is a hint, it is ultimately up to the look and feel to honor the return value in some meaningful way.

This implementation returns 0, indicating the AbstractColorChooserPanel does not support a mnemonic, subclasses wishing a mnemonic will need to override this.

Returns:int

KeyEvent.VK constant identifying the mnemonic; <= 0 for no mnemonic

Since
1.4
See Also
getDisplayedMnemonicIndex
getSmallDisplayIconback to summary
public abstract Icon getSmallDisplayIcon()

Returns the small display icon for the panel.

Returns:Icon

the small display icon

installChooserPanelback to summary
public void installChooserPanel(JColorChooser enclosingChooser)

Invoked when the panel is added to the chooser. If you override this, be sure to call super.

Parameters
enclosingChooser:JColorChooser

the chooser to which the panel is to be added

Exceptions
RuntimeException:
if the chooser panel has already been installed
isColorTransparencySelectionEnabledback to summary
public boolean isColorTransparencySelectionEnabled()

Gets whether color chooser panel allows to select the transparency (alpha value) of a color.

Returns:boolean

true if the transparency of a color can be selected

Since
9
See Also
setColorTransparencySelectionEnabled(boolean)
paintback to summary
public void paint(Graphics g)

Overrides javax.swing.JComponent.paint.

Draws the panel.

Parameters
g:Graphics

the Graphics object

setColorTransparencySelectionEnabledback to summary
public void setColorTransparencySelectionEnabled(boolean b)

Sets whether color chooser panel allows to select the transparency (alpha value) of a color. This method fires a property-changed event, using the string value of TRANSPARENCY_ENABLED_PROPERTY as the name of the property.

The value is a hint and may not be applicable to all types of chooser panel.

The default value is true.

Parameters
b:boolean

true if the transparency of a color can be selected

Annotations
@BeanProperty
description:Sets the transparency of a color selection on or off.
Since
9
See Also
isColorTransparencySelectionEnabled()
setSelectedColorback to summary
pack-priv void setSelectedColor(Color color)
uninstallChooserPanelback to summary
public void uninstallChooserPanel(JColorChooser enclosingChooser)

Invoked when the panel is removed from the chooser. If override this, be sure to call super.

Parameters
enclosingChooser:JColorChooser

the chooser from which the panel is to be removed

updateChooserback to summary
public abstract void updateChooser()

Invoked automatically when the model's state changes. It is also called by installChooserPanel to allow you to set up the initial state of your chooser. Override this method to update your ChooserPanel.