fwpUtil
Class ColorChooser


public class ColorChooser
extends javax.swing.JDialog
Title: Color chooser dialog.

Description: It integrates the fairly standard color chooser which allows specifying the color by using swatches, HSB or RGB tabs with an added alpha/transparency input.

Copyright: Copyright (c) 2011

Version:
1.0 - 2011

NOTE: This JavaDoc file was post processed with Microsoft FrontPage and regenerating the file will cause the graphics and format changes to be lost.

Author:
Fred Pospeschil - This file is placed in the public domain and can be used and adapted without restrictions. The user of the code is totally responsible for insuring its suitability in the intended application.
Constructor Detail

ColorChooser

public ColorChooser(java.awt.Frame parent)
Displays a dialog in which the user can select a color and an alpha (transparency) value.

A color chooser that allows users to pick a color in three different manners. The color selection is provided by a JColorChooser pane.

The dialog Can be called with ColorChooser fc = new ColorChooser(this); if a frame is avialable or it can be called with: ColorChooser fc = new ColorChooser(null); if a frame is not available.

If a frame is provided, the dialog is centered over that frame. Otherwise, the dialog is positioned 20 pixels down and to the right of the upper left corner of the display screen.

This dialog is an adaptation of the font chooser presented in Java Swing by Robert Eckstein, Marc Loy & Dave Wood, O'Reilly, Sebastopol, CA 1998, ISBN 1-56592-455-X

Parameters:
parent - The Frame from which the dialog was called.

Method Detail

getNewColor

public java.awt.Color getNewColor()
Returns the color that was selected by the user.
Returns:
A Color object with red, green, blue and alpha set. The alpha/transparency value is constrained to fall beween (inclusive) 1 and 255. If an invalid value is entered the program advises the user and sets the value to 255. The user then has the opportunity to enter another legal value.

Note: The alpha values set by the user do not change the transparency of the text shown by the color chooser but are returned in the color object.


toString

public java.lang.String toString()
Returns:
Provides a string representation of the selected color and color-alpha.

Example: java.awt.Color[r=255,g=51,b=51]Alpha=179