The Source for Java Technology Collaboration
User: Password:



Tim Boudreau's Blog

June 2006 Archives


A Single-Mouse-Gesture Color Chooser for Swing

Posted by timboudreau on June 05, 2006 at 05:56 PM | Permalink | Comments (1)

Ever needed a faster, slicker way to let your users select a color in Swing? I just set up a new java.net project, which produces just such a widget. Press the mouse and a palette pops up; drag over the palette and release when the color is right; use combinations of ctrl/alt/shift to switch palettes (palettes are pluggable if you want to write your own).

The widget is the Quick Color Chooser - net.dev.java.colorchooser.ColorChooser. It's a simple Swing widget with one property of interest - color - that is incredibly easy to use.

It's actually been sitting around in contrib/ on netbeans.org for a couple of years, and the palette code dates back to 2000 - it's a port of a Delphi component I wrote in the mid nineties. .

So the code is fairly mature and solid - I just split it out into having a separate UI delegate so it's more Swing-like and the painting behavior is overridable, but it's the same logic as before. Feedback appreciated.

If you want to try it using Matisse in NetBeans, there's a NetBeans module that installs the component in the component palette for immediate drag-and-drop use (created using BeanNetter). The module includes the javadoc.



Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds