1 /*
2 * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package javax.swing.colorchooser;
27
28 import java.awt.*;
29 import java.beans.PropertyChangeEvent;
30 import java.beans.PropertyChangeListener;
31 import javax.swing.*;
32
33 /**
34 * This is the abstract superclass for color choosers. If you want to add
35 * a new color chooser panel into a <code>JColorChooser</code>, subclass
36 * this class.
37 * <p>
38 * <strong>Warning:</strong>
39 * Serialized objects of this class will not be compatible with
40 * future Swing releases. The current serialization support is
41 * appropriate for short term storage or RMI between applications running
42 * the same version of Swing. As of 1.4, support for long term storage
43 * of all JavaBeans™
44 * has been added to the <code>java.beans</code> package.
45 * Please see {@link java.beans.XMLEncoder}.
46 *
47 * @author Tom Santos
48 * @author Steve Wilson
205 void setSelectedColor(Color color) {
206 ColorSelectionModel model = getColorSelectionModel();
207 if (model != null) {
208 model.setSelectedColor(color);
209 }
210 }
211
212 /**
213 * Sets whether color chooser panel allows to select the transparency
214 * (alpha value) of a color.
215 * This method fires a property-changed event, using the string value of
216 * {@code TRANSPARENCY_ENABLED_PROPERTY} as the name
217 * of the property.
218 *
219 * <p>The value is a hint and may not be applicable to all types of chooser
220 * panel.
221 *
222 * <p>The default value is {@code true}.
223 *
224 * @param b true if the transparency of a color can be selected
225 *
226 * @beaninfo
227 * bound: true
228 * description: Sets the transparency of a color selection on or off.
229 *
230 * @see #isColorTransparencySelectionEnabled()
231 */
232 public void setColorTransparencySelectionEnabled(boolean b){
233 }
234
235 /**
236 * Gets whether color chooser panel allows to select the transparency
237 * (alpha value) of a color.
238 *
239 * @return true if the transparency of a color can be selected
240 * @see #setColorTransparencySelectionEnabled(boolean)
241 */
242 public boolean isColorTransparencySelectionEnabled(){
243 return true;
244 }
245
246 /**
247 * Draws the panel.
248 * @param g the <code>Graphics</code> object
249 */
250 public void paint(Graphics g) {
251 super.paint(g);
|
1 /*
2 * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package javax.swing.colorchooser;
27
28 import java.awt.*;
29 import java.beans.BeanProperty;
30 import java.beans.PropertyChangeEvent;
31 import java.beans.PropertyChangeListener;
32 import javax.swing.*;
33
34 /**
35 * This is the abstract superclass for color choosers. If you want to add
36 * a new color chooser panel into a <code>JColorChooser</code>, subclass
37 * this class.
38 * <p>
39 * <strong>Warning:</strong>
40 * Serialized objects of this class will not be compatible with
41 * future Swing releases. The current serialization support is
42 * appropriate for short term storage or RMI between applications running
43 * the same version of Swing. As of 1.4, support for long term storage
44 * of all JavaBeans™
45 * has been added to the <code>java.beans</code> package.
46 * Please see {@link java.beans.XMLEncoder}.
47 *
48 * @author Tom Santos
49 * @author Steve Wilson
206 void setSelectedColor(Color color) {
207 ColorSelectionModel model = getColorSelectionModel();
208 if (model != null) {
209 model.setSelectedColor(color);
210 }
211 }
212
213 /**
214 * Sets whether color chooser panel allows to select the transparency
215 * (alpha value) of a color.
216 * This method fires a property-changed event, using the string value of
217 * {@code TRANSPARENCY_ENABLED_PROPERTY} as the name
218 * of the property.
219 *
220 * <p>The value is a hint and may not be applicable to all types of chooser
221 * panel.
222 *
223 * <p>The default value is {@code true}.
224 *
225 * @param b true if the transparency of a color can be selected
226 * @see #isColorTransparencySelectionEnabled()
227 */
228 @BeanProperty(description
229 = "Sets the transparency of a color selection on or off.")
230 public void setColorTransparencySelectionEnabled(boolean b){
231 }
232
233 /**
234 * Gets whether color chooser panel allows to select the transparency
235 * (alpha value) of a color.
236 *
237 * @return true if the transparency of a color can be selected
238 * @see #setColorTransparencySelectionEnabled(boolean)
239 */
240 public boolean isColorTransparencySelectionEnabled(){
241 return true;
242 }
243
244 /**
245 * Draws the panel.
246 * @param g the <code>Graphics</code> object
247 */
248 public void paint(Graphics g) {
249 super.paint(g);
|