New Color Chooser in JDK 7
Many changes in Swing will appear in JDK 7 including a new date chooser. I've recently noticed that the JColorChooser has also improved in JDK 7 adding new ways to select the color and adding support for transparency.
I'm quite please with it as for my photo editor Decoration I added a Transparency tab to the standard color chooser.
In Java 6 you have 3 tabs: Swatches, HSB (Hue, Saturation, Brightness) and RGB (Red, Green, Blue).
In Java 7 you have 5 tabs: Swatches, HSV (Hue, Saturation, Value), HSL (Hue, Saturation, Lightness), RGB (Red, Green, Blue) and CMYK (Cyan, Magenta, Yellow, blacK).
The HSV and HSL tabs have a transparency slider (from 0 to 100).
The RGB and CMYK tabs have an alpha slider (from 0 to 255).
Note also that the size of the JColorChooser window has increased.
And here are the screenshots:


(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)






Comments
barneypitt replied on Mon, 2009/10/12 - 1:45pm
Anew Hope replied on Mon, 2009/10/12 - 10:54pm
Mikael Grev replied on Tue, 2009/10/13 - 2:18am
It looks the same as it did in -98, so yes, it looks old. And ugly.
This probably falls under the saying: "it's expensive to be poor" but I don't understand why the governance of Java (Sun mostly I guess) isn't more sneaky in these matters.
If they were to poke in JColorChooser, why no make it a contest? The price doesn't have to be a million dollars, but maybe a contract to do 100 hours more? I mean, what a way to get a good programmer/designer team on board!
I and a Sun engineer (Sergey Malenkov) actually did a redesign of the color chooser almost two years year ago. Of course, it was just a design in Photoshop, but anyway, a good programmer would realize it in a couple of days. Tops. I think you would like it, it looked more like in Photoshop.
If you're short of resources (Sun again) you have to be inventive. Touching up a -98 app to Q4 -98 doesn't cut it. IMHO. Unless you have abandoned something, but then you should be frank about that too, so not to inject anger and dispair.
Cheers,
Mikael Grev
Mikael Grev replied on Tue, 2009/10/13 - 2:28am
Hmm, I felt I need to put my money where my mouth is and post the Color Chooser. It's not nice to complain without a concrete idea I have been taught.
Cheers,
Mikael
Richard Osbaldeston replied on Tue, 2009/10/13 - 8:08am
For more attractive Color Pickers what about:
Simply adding an alpha component to the existing dialog troubles me though. It could expose developers to bugs they hadnt had to deal with until now. It should really be a new component or have methods to turn it off (off by default?). Changing its contract and function this late in the game is just rude. The problems come from setting components with semi-transparent colors. Unless you *ALSO* set the component in question to be non-opaque (see opaque JComponent property) you will get horrible rendering artefacts due to Swing optimising its painting algorithm.
PS I like Mikael Grev's mock-up, though I'd prefer to be presented with the palette/swatches/color well first and then be able to drill down to the fill-on RGB/HSL.. picker. Either customising a close matching color from the quick picker or creating a new color.
- Richard
Richard Osbaldeston replied on Tue, 2009/10/13 - 8:20am
Also why don't the Black, Alpha & Transparency sliders in those screenshots also have radiobuttons? dont they work on the vertical slider too? why not? Whats the difference between Transparency and Alpha anyway?
Shouldnt the tabs be marked as non-opaque so the lighter selected tab background on Windows shows through rather than just a thin white top-border..? Looks raggedy, even losing the preview pane and making the whole dialog narrower by default, equalising widths and/or reposition the OK Cancel buttons would help (a small bit).
Peter Muellers replied on Thu, 2009/10/15 - 5:44pm
- The ability to easily move among different color selection modalities, such as choosing a swatch, selecting a point in a color component space, specifying a numeric component value or mixing colors
- The ability to select from a set of variants displayed alongside the current color
- The ability to create color palettes
- The ability to save custom colors
- The ability to save custom palettes
- The ability to undo and redo color adjustments (to facilitate experimentation)
- The ability to adjust components independently within a graphical depiction of the color component space such that a sample of the currently selected color appears at the point of adjustment
I created a color picker with these capabilities that I use in some of my applications. I also packaged it as an applet if anyone wants to experiment with it. It lacks some of the new Java 7 JColorChooser features including alpha selection and CMYK so it isn’t the “Holy Grail” of Java color pickers. It might, however, be useful fodder for someone setting out on a quest for said Holy Grail.john green green replied on Fri, 2009/10/23 - 6:11am
tretrettgtrtr (not verified) replied on Sat, 2010/01/02 - 5:09pm
tretrettgtrtr (not verified) replied on Sat, 2010/01/02 - 5:10pm
tretrettgtrtr (not verified) replied on Sat, 2010/01/02 - 5:10pm
David Grren replied on Sat, 2010/09/25 - 9:44pm
David Grren replied on Sat, 2010/09/25 - 9:46pm
marissa (not verified) replied on Mon, 2010/11/15 - 12:07pm
Bonnie Rait replied on Tue, 2010/11/16 - 2:45pm
Gustavo Farm replied on Fri, 2011/05/06 - 9:55am