JDK-6242279 : Add a java.awt.Robot.getPixelColor(x,y) based panel to JColorChooser
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-03-17
  • Updated: 2017-05-23
Related Reports
Relates :  
Description
A DESCRIPTION OF THE REQUEST :
The java.awt.Robot was added to J2SE since 1.3. It has an API to sample the color of any pixel on the desktop using the getPixelColor(x, y) API. This API could be used to build a color sampler which can be added as one of the tabs on JColorChooser.

JUSTIFICATION :
Sometimes the user simply wants to choose a color from another window on the desktop. It is easy to simply sample it somehow instead of guessing it or trying to match it with one's eyes.

---------- BEGIN SOURCE ----------
Source code with a sample implementation has been added to the attachments. There's the panel itself (ColorSampler) and then an implementation that shows how this can be added as a panel to a JColorChooser, ColorSamplerColorChooserPanel. This latter class is runnable and demos the JColorChooser with this custom panel.
---------- END SOURCE ----------

This of course need to productized and tested with modal/non modal scenarios.

###@###.### 2005-03-17 19:20:32 GMT

Comments
EVALUATION Implementing this goes most of the way to solving 4869100, which complains that this functionality is missing from the GTK JColorChooser but exists in the native chooser. ###@###.### 2005-03-17 18:52:10 GMT I love this idea, and it's not often that we receive something like this that's almost ready to go. A couple things will need to be investigated: a) I saw problems with the mouse cursor when dragging out of the dialog b) This seems to be setting the color String onto the clipboard and we wouldn't want that. c) We'll want to talk to the UE team to see what kind of UI they want. GTK L&F will be different (4869100) but can probably use some of this source code. d) we'd need to deal specially with robot for applets (wonder if this can go in doPrivileged...). ###@###.### 2005-03-17 19:34:12 GMT
17-03-2005