99
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 Example with ActionListener
Output:
Next TopicJava JTabbedPane