buoy.widget

Class BColorChooser


public class BColorChooser
extends Widget

A BColorChooser is a Widget that allows the user to select a color. It has tabs which provide various ways of choosing the color, such as selecting one from a palette or specifying values for hue, saturation, and brightness.

BColorChooser can be used in two different ways. First, it can be added to a container like any other Widget. This is useful when you want it to appear inside of a window along with other Widgets.

Most often, however, BColorChooser is used in a modal dialog as a self contained user interface element. To use it this way, you simply instantiate a BColorChooser, set any properties, and then call showDialog() to display it. showDialog() will automatically create a dialog, add the BColorChooser, display it, and block until the user dismisses the dialog. You can reuse a single BColorChooser by repeatedly calling showDialog().

In addition to the event types generated by all Widgets, BColorChoosers generate the following event types:

Author:
Peter Eastman

Constructor Summary

BColorChooser()
Create a new BColorChooser whose initial color is white.
BColorChooser(Color color, String title)
Create a new BColorChooser

Method Summary

Color
getColor()
Get the color selected in the BColorChooser.
JColorChooser
getComponent()
String
getTitle()
Get the title displayed on the dialog.
void
setColor(Color color)
Set the color selected in the BColorChooser.
void
setTitle(String title)
Set the title displayed on the dialog.
boolean
showDialog(Widget parent)
Show a dialog containing this BColorChooser and block until the user closes it.

Methods inherited from class buoy.widget.Widget

addEventLink, dispatchEvent, getBackground, getBounds, getComponent, getCursor, getFont, getMaximumSize, getMinimumSize, getName, getParent, getPreferredSize, hasFocus, isEnabled, isFocusable, isVisible, repaint, requestFocus, setBackground, setCursor, setEnabled, setFocusable, setFont, setName, setVisible

Methods inherited from class buoy.event.EventSource

addEventLink, addEventLink, addEventLink, dispatchEvent, removeEventLink

Constructor Details

BColorChooser

public BColorChooser()
Create a new BColorChooser whose initial color is white.

BColorChooser

public BColorChooser(Color color,
                     String title)
Create a new BColorChooser
Parameters:
color - the color which is initially selected
title - the title to display on the dialog

Method Details

getColor

public Color getColor()
Get the color selected in the BColorChooser.

getComponent

public JColorChooser getComponent()
Overrides:
getComponent in interface Widget

getTitle

public String getTitle()
Get the title displayed on the dialog.

setColor

public void setColor(Color color)
Set the color selected in the BColorChooser.

setTitle

public void setTitle(String title)
Set the title displayed on the dialog.

showDialog

public boolean showDialog(Widget parent)
Show a dialog containing this BColorChooser and block until the user closes it. After this method returns, you can call getColor() to determine what color was selected.
Parameters:
parent - the dialog's parent Widget (usually a WindowWidget). This may be null.
Returns:
true if the user clicked the OK button, false if they clicked the cancel button

Written by Peter Eastman.