Javatpoint Logo
Javatpoint Logo

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:

Constructor Description
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:

Method Description
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
Next TopicJava JTabbedPane




Please Share

facebook twitter google plus pinterest tumbler

Latest 4 Tutorials