src/share/classes/javax/swing/colorchooser/DefaultColorSelectionModel.java

Print this page


   1 /*
   2  * Copyright (c) 1998, 2001, 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 javax.swing.*;
  29 import javax.swing.event.*;
  30 import java.awt.Color;
  31 import java.io.Serializable;
  32 
  33 /**
  34  * A generic implementation of <code>ColorSelectionModel</code>.
  35  *
  36  * @author Steve Wilson
  37  *
  38  * @see java.awt.Color
  39  */

  40 public class DefaultColorSelectionModel implements ColorSelectionModel, Serializable {
  41 
  42     /**
  43      * Only one <code>ChangeEvent</code> is needed per model instance
  44      * since the event's only (read-only) state is the source property.
  45      * The source of events generated here is always "this".
  46      */
  47     protected transient ChangeEvent changeEvent = null;
  48 
  49     protected EventListenerList listenerList = new EventListenerList();
  50 
  51     private Color selectedColor;
  52 
  53     /**
  54      * Creates a <code>DefaultColorSelectionModel</code> with the
  55      * current color set to <code>Color.white</code>.  This is
  56      * the default constructor.
  57      */
  58     public DefaultColorSelectionModel() {
  59         selectedColor = Color.white;


   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 javax.swing.*;
  29 import javax.swing.event.*;
  30 import java.awt.Color;
  31 import java.io.Serializable;
  32 
  33 /**
  34  * A generic implementation of <code>ColorSelectionModel</code>.
  35  *
  36  * @author Steve Wilson
  37  *
  38  * @see java.awt.Color
  39  */
  40 @SuppressWarnings("serial") // Same-version serialization only
  41 public class DefaultColorSelectionModel implements ColorSelectionModel, Serializable {
  42 
  43     /**
  44      * Only one <code>ChangeEvent</code> is needed per model instance
  45      * since the event's only (read-only) state is the source property.
  46      * The source of events generated here is always "this".
  47      */
  48     protected transient ChangeEvent changeEvent = null;
  49 
  50     protected EventListenerList listenerList = new EventListenerList();
  51 
  52     private Color selectedColor;
  53 
  54     /**
  55      * Creates a <code>DefaultColorSelectionModel</code> with the
  56      * current color set to <code>Color.white</code>.  This is
  57      * the default constructor.
  58      */
  59     public DefaultColorSelectionModel() {
  60         selectedColor = Color.white;