# JColorPicker Demo

## What Is It

The `com.pump.swing.JColorPicker` is an alternative to Swing's default `javax.swing.JColorChooser` that presents a color wheel and other Photoshop-inspired UI controls.

## How To Use It

You can create a `JColorPicker` that can be inserted anywhere in your UI by calling:

    JColorPicker picker = new JColorPicker(true, false);
    picker.addPropertyChangeListener(JColorPicker.SELECTED_COLOR_PROPERTY, pcl);

Or you can invoke a modal dialog by calling:

    boolean includeOpacity = true;
    Color c = JColorPicker.showDialog(window, initialColor, includeOpacity);

`

## How It Works

The `JColorPicker` mostly manages the data model and a series of UI controls that can be toggled on/off as needed. Since a color is generally represented by 3 numbers and our UI can only present 2D data (either as a rectangle or a circle): we end up holding one number constant. The default constant is "Brightness", but the JColorPicker (and this demo) lets you choose any of the 6 values: red, green, blue, hue, saturation, brightness.

The `JColorPickerPanel` is the JComponent that actually renders the large gradient wheel/rectangle. The JColorPicker, by contrast, is the container that embeds the JColorPickerPanel and dozens of other UI controls.

## Discussion

The original motivation for this class was simple: I didn't like how the `JColorChooser` looks:

Personally I think palettes are the best way to choose a color (so the JColorChooser is off to a good start), but specifically my main critiques include:

- This default palette doesn't include a white and black option. Also it's pretty lacking in browns.
- This default palette has lots of dead space. We know that's because of the other tabs, but still: it looks unpolished.
- The "Preview" section feels awfully bloated. And anymore I'd suggest: your app should be making undoable/previewable changes in real-time, so the whole concept of a "Preview" section might be outdated.
- More broadly: I don't like offering 3 tabs of UIs to choose a color. If possible (and sometimes it may not be possible): I'd prefer to just pick one model and stick to that. Don't overwhelm the user with lots of choices. But I concede if you're audience is impossibly broad: sometimes a UI like this is an acceptable tax on the user's attention.

The JColorPicker is loosely modeled after options I observed in Photoshop. (But as a disclaimer: I wrote it over a decade ago, and I haven't opened Photoshop lately.) My ideal usage is to pick just one view (usually a brightness-based wheel) and not let the user further configure it.

The JColorWell is a separate component that offers both a palette and a dialog. The JColorPicker is what I consider the "most advanced" option. I want to use it when the user has signaled that they want really granular control over their color choice.