/[classpath]/classpath/javax/swing/colorchooser/DefaultColorSelectionModel.java
ViewVC logotype

Diff of /classpath/javax/swing/colorchooser/DefaultColorSelectionModel.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by mkoch, Sun Jun 8 12:14:56 2003 UTC revision 1.4 by mkoch, Wed Jul 2 05:21:52 2003 UTC
# Line 52  import javax.swing.event.EventListenerLi Line 52  import javax.swing.event.EventListenerLi
52  public class DefaultColorSelectionModel  public class DefaultColorSelectionModel
53    implements ColorSelectionModel, Serializable    implements ColorSelectionModel, Serializable
54  {  {
55    static final long serialVersionUID = 580150227676302096L;    private static final long serialVersionUID = -8117143602864778804L;
56    
57          //-------------------------------------------------------------    private Color selectedColor;
         // Variables --------------------------------------------------  
         //-------------------------------------------------------------  
   
         /**  
          * changeEvent  
          */  
         protected transient ChangeEvent changeEvent;  
   
         /**  
          * listenerList  
          */  
         protected EventListenerList listenerList;  
   
         /**  
          * selectedColor  
          */  
         private Color selectedColor;  
   
   
         //-------------------------------------------------------------  
         // Initialization ---------------------------------------------  
         //-------------------------------------------------------------  
   
         /**  
          * Constructor DefaultColorSelectionModel  
          */  
         public DefaultColorSelectionModel() {  
                 // TODO  
         } // DefaultColorSelectionModel()  
   
         /**  
          * Constructor DefaultColorSelectionModel  
          * @param color TODO  
          */  
         public DefaultColorSelectionModel(Color color) {  
                 // TODO  
         } // DefaultColorSelectionModel()  
   
   
         //-------------------------------------------------------------  
         // Methods ----------------------------------------------------  
         //-------------------------------------------------------------  
   
         /**  
          * getSelectedColor  
          * @returns Color  
          */  
         public Color getSelectedColor() {  
                 return null; // TODO  
         } // getSelectedColor()  
   
         /**  
          * setSelectedColor  
          * @param color TODO  
          */  
         public void setSelectedColor(Color color) {  
                 // TODO  
         } // setSelectedColor()  
   
         /**  
          * addChangeListener  
          * @param listener TODO  
          */  
         public void addChangeListener(ChangeListener listener) {  
                 // TODO  
         } // addChangeListener()  
   
         /**  
          * removeChangeListener  
          * @param listener TODO  
          */  
         public void removeChangeListener(ChangeListener listener) {  
                 // TODO  
         } // removeChangeListener()  
   
         /**  
          * fireStateChanged  
          */  
         protected void fireStateChanged() {  
                 // TODO  
         } // fireStateChanged()  
58    
59      protected transient ChangeEvent changeEvent = new ChangeEvent (this);
60      protected EventListenerList listenerList = new EventListenerList ();
61    
62  } // DefaultColorSelectionModel    /**
63       * Creates a new color selection model.
64       */
65      public DefaultColorSelectionModel()
66      {
67        this (Color.white);
68      }
69    
70      /**
71       * Creates a new color selection model with a given selected color.
72       *
73       * @param color The selected color.
74       */
75      public DefaultColorSelectionModel (Color color)
76      {
77        super();
78        this.selectedColor = color;
79      }
80    
81      /**
82       * Returns the selected color.
83       *
84       * @return The selected color.
85       */
86      public Color getSelectedColor()
87      {
88        return selectedColor;
89      }
90    
91      /**
92       * @param color The color to set.
93       */
94      public void setSelectedColor (Color color)
95      {
96        this.selectedColor = color;
97      }
98    
99      /**
100       * Adds a listener to this model.
101       *
102       * @param listener The listener to add.
103       */
104      public void addChangeListener (ChangeListener listener)
105      {
106        listenerList.add (ChangeListener.class, listener);
107      }
108    
109      /**
110       * Removes a listener from this model.
111       *
112       * @param listener The listener to remove.
113       */
114      public void removeChangeListener (ChangeListener listener)
115      {
116        listenerList.remove (ChangeListener.class, listener);
117      }
118    
119      /**
120       * Returns all currently added <code>ChangeListener</code> objects.
121       *
122       * @return Array of <code>ChangeListener</code> objects.
123       */
124      public ChangeListener[] getChangeListeners()
125      {
126        return (ChangeListener[]) listenerList.getListeners (ChangeListener.class);
127      }
128    
129      /**
130       * Calls all the <code>stateChanged()</code> method of all added
131       * <code>ChangeListener</code> objects with <code>changeEvent</code>
132       * as argument.
133       */
134      protected void fireStateChanged()
135      {
136        ChangeListener[] listeners = getChangeListeners();
137    
138        for (int i = 0; i < listeners.length; i++)
139          listeners [i].stateChanged (changeEvent);
140      }
141    }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26