Java JColorChooser

The JColorChooser class is used to create a color chooser dialog box so that user can select any color. It inherits JComponent class.

JColorChooser class declaration

Let's see the declaration for javax.swing.JColorChooser class.

Commonly used Constructors:

ConstructorDescription
JColorChooser()It is used to create a color chooser panel with white color initially.
JColorChooser(color initialcolor)It is used to create a color chooser panel with the specified color initially.

Commonly used Methods:

MethodDescription
void addChooserPanel(AbstractColorChooserPanel panel)It is used to add a color chooser panel to the color chooser.
static Color showDialog(Component c, String title, Color initialColor)It is used to show the color chooser dialog box.

Java JColorChooser Example

Output:

JAVA Jcolorchooser 1

Java JColorChooser Example with ActionListener

Output:

JAVA Jcolorchooser 2 JAVA Jcolorchooser 3