buoy.widget
Class BColorChooser

java.lang.Object
  extended by buoy.event.EventSource
      extended by buoy.widget.Widget
          extended by buoy.widget.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(java.awt.Color color, java.lang.String title)
          Create a new BColorChooser
 
Method Summary
 java.awt.Color getColor()
          Get the color selected in the BColorChooser.
 javax.swing.JColorChooser getComponent()
          Get the java.awt.Component corresponding to this Widget.
 java.lang.String getTitle()
          Get the title displayed on the dialog.
 void setColor(java.awt.Color color)
          Set the color selected in the BColorChooser.
 void setTitle(java.lang.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, 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, removeEventLink
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BColorChooser

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


BColorChooser

public BColorChooser(java.awt.Color color,
                     java.lang.String title)
Create a new BColorChooser

Parameters:
color - the color which is initially selected
title - the title to display on the dialog
Method Detail

getComponent

public javax.swing.JColorChooser getComponent()
Description copied from class: Widget
Get the java.awt.Component corresponding to this Widget.

Overrides:
getComponent in class Widget

getTitle

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


setTitle

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


getColor

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


setColor

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


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.