Class CSSColorChooserPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class CSSColorChooserPanel extends AbstractColorChooserPanel
Color-chooser panel for CSS named colors. An instance of this class can be installed into a color chooser to provide an option to select CSS named colors. The panel will allow the color to be selected by using an array of swatches or to be selected by name. A separate control sets the Alpha value. The typical usage of this class is as follows:

    Component c ... ;
    Color color = ... ;

    void example() {
        boolean modal = true;
        JColorChooser cc = new JColorChooser(color);
        cc.addChooserPanel(new CSSColorChooserPanel());
        JDialog dialog = JColorChooser.createDialog
             (c, "Color Chooser", modal, cc,
              (e) -> {
                  // Color accepted
                  color = cc.getColor();
                },
              (e) -> {
                  // Dialog was canceled and
                  // previous color kept.
              });
        dialog.setVisible(true);
   }
 
See Also: