This was originally intended to replace the JColorChooser
. To use this class to create a color choosing dialog, simply call: ColorPicker.showDialog(frame, originalColor);
However this panel is also resizable, and it can exist in other contexts. For example, you might try the following panel: ColorPicker picker = new ColorPicker(false, false);
picker.setPreferredSize(new Dimension(200,160));
picker.setMode(ColorPicker.HUE);
This will create a miniature color picker that still lets the user choose from every available color, but it does not include all the buttons and numeric controls on the right side of the panel. This might be ideal if you are working with limited space, or non-power-users who don't need the RGB values of a color. The main()
method of this class demonstrates possible ways you can customize a ColorPicker
component.
To listen to color changes to this panel, you can add a PropertyChangeListener
listening for changes to the SELECTED_COLOR_PROPERTY
. This will be triggered only when the RGB value of the selected color changes.
To listen to opacity changes to this panel, use a PropertyChangeListener
listening for changes to the OPACITY_PROPERTY
.
|
|
|
|