3261N/A * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * <code>JColorChooser</code> provides a pane of controls designed to allow 0N/A * a user to manipulate and select a color. 0N/A * For information about using color choosers, see 0N/A * a section in <em>The Java Tutorial</em>. 0N/A * This class provides three levels of API: 0N/A * <li>A static convenience method which shows a modal color-chooser 0N/A * dialog and returns the color selected by the user. 0N/A * <li>A static convenience method for creating a color-chooser dialog 0N/A * where <code>ActionListeners</code> can be specified to be invoked when 0N/A * the user presses one of the dialog buttons. 0N/A * <li>The ability to create instances of <code>JColorChooser</code> panes 0N/A * directly (within any container). <code>PropertyChange</code> listeners 0N/A * can be added to detect when the current "color" property changes. 0N/A * <strong>Warning:</strong> Swing is not thread safe. For more 0N/A * information see <a 0N/A * <strong>Warning:</strong> 0N/A * Serialized objects of this class will not be compatible with 0N/A * future Swing releases. The current serialization support is 0N/A * appropriate for short term storage or RMI between applications running 0N/A * the same version of Swing. As of 1.4, support for long term storage 0N/A * of all JavaBeans<sup><font size="-2">TM</font></sup> 0N/A * has been added to the <code>java.beans</code> package. 0N/A * attribute: isContainer false 0N/A * description: A component that supports selecting a Color. 0N/A * @author James Gosling 0N/A * @author Amy Fowler 0N/A * @author Steve Wilson 0N/A * @see #getUIClassID 0N/A * The selection model property name. 0N/A * The preview panel property name. 0N/A * The chooserPanel array property name. 0N/A * Shows a modal color-chooser dialog and blocks until the 0N/A * dialog is hidden. If the user presses the "OK" button, then 0N/A * If the user presses the "Cancel" button or closes the dialog without 0N/A * <code>null</code>. 0N/A * @param component the parent <code>Component</code> for the dialog 0N/A * @param title the String containing the dialog's title 0N/A * @param initialColor the initial Color set when the color-chooser is shown 0N/A * @return the selected color or <code>null</code> if the user opted out 0N/A * @exception HeadlessException if GraphicsEnvironment.isHeadless() 0N/A * @see java.awt.GraphicsEnvironment#isHeadless 0N/A * Creates and returns a new dialog containing the specified 0N/A * <code>ColorChooser</code> pane along with "OK", "Cancel", and "Reset" 0N/A * buttons. If the "OK" or "Cancel" buttons are pressed, the dialog is 0N/A * automatically hidden (but not disposed). If the "Reset" 0N/A * button is pressed, the color-chooser's color will be reset to the 0N/A * color which was set the last time <code>show</code> was invoked on the 0N/A * dialog and the dialog will remain showing. 0N/A * @param c the parent component for the dialog 0N/A * @param title the title for the dialog 0N/A * @param modal a boolean. When true, the remainder of the program 0N/A * is inactive until the dialog is closed. 0N/A * @param chooserPane the color-chooser to be placed inside the dialog 0N/A * @param okListener the ActionListener invoked when "OK" is pressed 0N/A * @param cancelListener the ActionListener invoked when "Cancel" is pressed 0N/A * @return a new dialog containing the color-chooser pane 0N/A * @exception HeadlessException if GraphicsEnvironment.isHeadless() 0N/A * @see java.awt.GraphicsEnvironment#isHeadless 0N/A * Creates a color chooser pane with an initial color of white. 0N/A * Creates a color chooser pane with the specified initial color. 0N/A * @param initialColor the initial color set in the chooser 0N/A * Creates a color chooser pane with the specified 0N/A * <code>ColorSelectionModel</code>. 0N/A * @param model the <code>ColorSelectionModel</code> to be used 0N/A * Returns the L&F object that renders this component. 0N/A * @return the <code>ColorChooserUI</code> object that renders 0N/A * Sets the L&F object that renders this component. 0N/A * @param ui the <code>ColorChooserUI</code> L&F object 0N/A * @see UIDefaults#getUI 0N/A * description: The UI object that implements the color chooser's LookAndFeel. 0N/A * Notification from the <code>UIManager</code> that the L&F has changed. 0N/A * Replaces the current UI object with the latest version from the 0N/A * <code>UIManager</code>. 0N/A * @see JComponent#updateUI 0N/A * Returns the name of the L&F class that renders this component. 0N/A * @return the string "ColorChooserUI" 0N/A * @see JComponent#getUIClassID 0N/A * @see UIDefaults#getUI 0N/A * Gets the current color value from the color chooser. 0N/A * By default, this delegates to the model. 0N/A * @return the current color value of the color chooser 0N/A * Sets the current color of the color chooser to the specified color. 0N/A * The <code>ColorSelectionModel</code> will fire a <code>ChangeEvent</code> 0N/A * @param color the color to be set in the color chooser 0N/A * @see JComponent#addPropertyChangeListener 0N/A * description: The current color the chooser is to display. 0N/A * Sets the current color of the color chooser to the 0N/A * specified RGB color. Note that the values of red, green, 0N/A * and blue should be between the numbers 0 and 255, inclusive. 0N/A * @param r an int specifying the amount of Red 0N/A * @param g an int specifying the amount of Green 0N/A * @param b an int specifying the amount of Blue 0N/A * @exception IllegalArgumentException if r,g,b values are out of range 0N/A * @see java.awt.Color 0N/A * Sets the current color of the color chooser to the 0N/A * @param c an integer value that sets the current color in the chooser 0N/A * where the low-order 8 bits specify the Blue value, 0N/A * the next 8 bits specify the Green value, and the 8 bits 0N/A * above that specify the Red value. 0N/A * Sets the <code>dragEnabled</code> property, 0N/A * which must be <code>true</code> to enable 0N/A * automatic drag handling (the first part of drag and drop) 0N/A * on this component. 0N/A * The <code>transferHandler</code> property needs to be set 0N/A * to a non-<code>null</code> value for the drag to do 0N/A * anything. The default value of the <code>dragEnabled</code> 0N/A * is <code>false</code>. 0N/A * When automatic drag handling is enabled, 0N/A * most look and feels begin a drag-and-drop operation 0N/A * when the user presses the mouse button over the preview panel. 0N/A * Some look and feels might not support automatic drag and drop; 0N/A * they will ignore this property. You can work around such 0N/A * look and feels by modifying the component 0N/A * to directly call the <code>exportAsDrag</code> method of a 0N/A * <code>TransferHandler</code>. 0N/A * @param b the value to set the <code>dragEnabled</code> property to 0N/A * @exception HeadlessException if 0N/A * <code>b</code> is <code>true</code> and 0N/A * <code>GraphicsEnvironment.isHeadless()</code> 0N/A * returns <code>true</code> 0N/A * @see java.awt.GraphicsEnvironment#isHeadless 0N/A * @see #getDragEnabled 0N/A * @see #setTransferHandler 0N/A * @see TransferHandler 0N/A * description: Determines whether automatic drag handling is enabled. 0N/A * Gets the value of the <code>dragEnabled</code> property. 0N/A * @return the value of the <code>dragEnabled</code> property 0N/A * @see #setDragEnabled 0N/A * Sets the current preview panel. 0N/A * This will fire a <code>PropertyChangeEvent</code> for the property 0N/A * named "previewPanel". 0N/A * @param preview the <code>JComponent</code> which displays the current color 0N/A * @see JComponent#addPropertyChangeListener 0N/A * description: The UI component which displays the current color. 0N/A * Returns the preview panel that shows a chosen color. 0N/A * @return a <code>JComponent</code> object -- the preview panel 0N/A * Adds a color chooser panel to the color chooser. 0N/A * @param panel the <code>AbstractColorChooserPanel</code> to be added 0N/A * Removes the Color Panel specified. 0N/A * @param panel a string that specifies the panel to be removed 0N/A * @return the color panel 0N/A * @exception IllegalArgumentException if panel is not in list of 0N/A * known chooser panels 0N/A * Specifies the Color Panels used to choose a color value. 0N/A * @param panels an array of <code>AbstractColorChooserPanel</code> 0N/A * description: An array of different chooser types. 0N/A * Returns the specified color panels. 0N/A * @return an array of <code>AbstractColorChooserPanel</code> objects 0N/A * Returns the data model that handles color selections. 0N/A * @return a <code>ColorSelectionModel</code> object 0N/A * Sets the model containing the selected color. 0N/A * @param newModel the new <code>ColorSelectionModel</code> object 0N/A * description: The model which contains the currently selected color. 0N/A * See <code>readObject</code> and <code>writeObject</code> in 0N/A * <code>JComponent</code> for more 0N/A * information about serialization in Swing. 0N/A * Returns a string representation of this <code>JColorChooser</code>. 0N/A * is intended to be used only for debugging purposes, and the 0N/A * content and format of the returned string may vary between 0N/A * implementations. The returned string may be empty but may not 0N/A * be <code>null</code>. 0N/A * @return a string representation of this <code>JColorChooser</code> 0N/A// Accessibility support 0N/A * Gets the AccessibleContext associated with this JColorChooser. 0N/A * For color choosers, the AccessibleContext takes the form of an 0N/A * AccessibleJColorChooser. 0N/A * A new AccessibleJColorChooser instance is created if necessary. 0N/A * @return an AccessibleJColorChooser that serves as the 0N/A * AccessibleContext of this JColorChooser 0N/A * This class implements accessibility support for the 0N/A * <code>JColorChooser</code> class. It provides an implementation of the 0N/A * Java Accessibility API appropriate to color chooser user-interface 0N/A * Get the role of this object. 0N/A * @return an instance of AccessibleRole describing the role of the 0N/A * @see AccessibleRole 0N/A }
// inner class AccessibleJColorChooser 0N/A * Class which builds a color chooser dialog consisting of 0N/A * a JColorChooser with "Ok", "Cancel", and "Reset" buttons. 0N/A * Note: This needs to be fixed to deal with localization! 0N/A //setResizable(false); 0N/A * Create Lower button panel 0N/A // The following few lines are used to register esc to close the dialog