Anthony Goubard is a freelance Senior Software Engineer from Amsterdam. He has developed in Java since 1995. He has developed many softwares available at http://www.japplis.com and is the main developer of the Web Services framework XINS. Anthony is a DZone MVB and is not an employee of DZone and has posted 33 posts at DZone. You can read more from them at their website. View Full User Profile

New Color Chooser in JDK 7

10.12.2009
| 21851 views |
  • submit to reddit

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:
The new color chooser of Java 7
The new color chooser of Java 7

From http://www.jroller.com/agoubard

Published at DZone with permission of Anthony Goubard, author and DZone MVB.

(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

Looks like an absolute triumph of clunkiness. Ludicrously oversized, tonnes of wasted space, and still retains that nineties feel.

Anew Hope replied on Mon, 2009/10/12 - 10:54pm

@barneypitt I understand what you are saying but your comments apply to swing in general I think. This addition is extremely welcome since transparency, while available on most platforms, was not available via the JColorChooser. Unfortunately most java GUI designers relied on the the chooser instead of creating their own which left you to hand code the transparency (assuming the tool was generating java code). This will be a boon for Netbeans users.

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

 Color Chooser

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

I’d like to toss out some more ideas for capabilities of an “ideal” Java color picker:
  1. 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
  2. The ability to select from a set of variants displayed alongside the current color
  3. The ability to create color palettes
  4. The ability to save custom colors
  5. The ability to save custom palettes
  6. The ability to undo and redo color adjustments (to facilitate experimentation)
  7. 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

PS I like Mikael Grev's mock-up, though I'd prefer to be presented with nike shoes discount 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.

tretrettgtrtr (not verified) replied on Sat, 2010/01/02 - 5:09pm

A游戏一起去

tretrettgtrtr (not verified) replied on Sat, 2010/01/02 - 5:10pm

sunrise1 replied on Fri, 2009/10/23 - 6:11amPS I like Mikael Grev's mock-up, though I'd prefer to be presented with nike shoes discount 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.

tretrettgtrtr (not verified) replied on Sat, 2010/01/02 - 5:10pm

RETRETA游戏一起去TRETRE

David Grren replied on Sat, 2010/09/25 - 9:44pm

The RGB and CMYK tabs have an alpha slider (from 0 to 255). Note also that the size of the JColorChooser window has increased.java

David Grren replied on Sat, 2010/09/25 - 9:46pm

Could Smart Grid, the Obama Administration's effort to modernize the nation's electric grid, be the killer app for IPv6?java

marissa (not verified) replied on Mon, 2010/11/15 - 12:07pm

"Shouldn't 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, equalizing widths and/or reposition the OK Cancel buttons would help (a small bit)." Absolutely! I agree! Also, if you are interested, please take a look at belly after pregnancy and post pregnancy tummy trimming methods.

Bonnie Rait replied on Tue, 2010/11/16 - 2:45pm

This is a great resource to use to put color coded keypads on access control systems and also to color code corresponding websites.  Way to go!

Gustavo Farm replied on Fri, 2011/05/06 - 9:55am

It's the first time that I get to hear about a new date chooser that might appear in JDK 7. It reminded me that I have a project about the bees pollen so I better be moving. Thanks for providing this information.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.