All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.java.swing.JColorChooser

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----com.sun.java.swing.JComponent
                           |
                           +----com.sun.java.swing.JColorChooser

public class JColorChooser
extends JComponent
implements Serializable
JColorChooser provides pane of controls designed to allow a user to manipulate and select a color. This class provides 3 levels of API:
  1. A static convenience method which shows a modal color-chooser dialog and returns the color selected by the user.
  2. A static convenience method for creating a color-chooser dialog where ActionListeners can be specified to be invoked when the user presses one of the dialog buttons.
  3. The ability to create instances of JColorChooser panes directly (within any container). PropertyChange listeners can be added to detect when the current "color" property changes.

    See Also:
    addPropertyChangeListener , JColorSwatch

    Variable Index

     o COLOR_PROPERTY
    The color property name.

    Constructor Index

     o JColorChooser()
    Creates a color-chooser pane with an initial color of white.
     o JColorChooser(Color)
    Creates a color-chooser pane with the specified initial color.

    Method Index

     o createDialog(Component, String, boolean, JColorChooser, ActionListener, ActionListener)
    Creates and returns a new dialog containing the specified ColorChooser pane along with "OK", "Cancel", and "Reset" buttons.
     o getColor()
    Gets the current color set in the color chooser.
     o getIntColor()
    Gets the current color set in the color chooser.
     o setColor(Color)
    Sets the current color of the color chooser to the specified color.
     o setColor(int)
    Sets the current color of the color chooser to the specified color.
     o setColor(int, int, int)
    Sets the current color of the color chooser to the specified RGB color.
     o showDialog(Component, String, Color)
    Shows a modal color-chooser dialog and blocks until the dialog is hidden.

    Variables

     o COLOR_PROPERTY
     public static final String COLOR_PROPERTY
    
    The color property name.

    Constructors

     o JColorChooser
     public JColorChooser()
    
    Creates a color-chooser pane with an initial color of white.

     o JColorChooser
     public JColorChooser(Color initialColor)
    
    Creates a color-chooser pane with the specified initial color.

    Parameters:
    initialColor - the initial color set in the chooser

    Methods

     o showDialog
     public static Color showDialog(Component component,
                                    String title,
                                    Color initialColor)
    
    Shows a modal color-chooser dialog and blocks until the dialog is hidden. If the user presses the "OK" button, then this method hides/disposes the dialog and returns the selected color. If the user presses the "Cancel" button or closes the dialog without pressing "OK", then this method hides/disposes the dialog and returns null.

    Parameters:
    c - the parent component for the dialog
    title - the title for the dialog
    initialColor - the initial color set when the color-chooser is shown
     o createDialog
     public static JDialog createDialog(Component c,
                                        String title,
                                        boolean modal,
                                        JColorChooser chooserPane,
                                        ActionListener okListener,
                                        ActionListener cancelListener)
    
    Creates and returns a new dialog containing the specified ColorChooser pane along with "OK", "Cancel", and "Reset" buttons. If the "OK" or "Cancel" buttons are pressed, the dialog is automatically hidden (but not disposed). If the "Reset" button is pressed, the color-chooser's color will be reset to the color which was set the last time show() was invoked on the dialog and the dialog will remain showing.

    Parameters:
    c - c the parent component for the dialog
    title - the title for the dialog
    modal - whether or not the dialog is modal
    chooserPane - the color-chooser to be placed inside the dialog
    okListener - the ActionListener invoked when "OK" is pressed
    cancelListener - the ActionListener invoked when "Cancel" is pressed
     o setColor
     public void setColor(int r,
                          int g,
                          int b)
    
    Sets the current color of the color chooser to the specified RGB color.

     o setColor
     public void setColor(Color c)
    
    Sets the current color of the color chooser to the specified color.

    Parameters:
    c - the color to be set in the chooser
     o setColor
     public void setColor(int c)
    
    Sets the current color of the color chooser to the specified color.

     o getColor
     public Color getColor()
    
    Gets the current color set in the color chooser.

     o getIntColor
     public int getIntColor()
    
    Gets the current color set in the color chooser.


    All Packages  Class Hierarchy  This Package  Previous  Next  Index