< prev index next >

src/share/classes/javax/swing/DefaultSingleSelectionModel.java

Print this page
rev 1527 : 6727662: Code improvement and warnings removing from swing packages
Summary: Removed unnecessary castings and other warnings
Reviewed-by: malenkov


  93      * Removes a <code>ChangeListener</code> from the button.
  94      */
  95     public void removeChangeListener(ChangeListener l) {
  96         listenerList.remove(ChangeListener.class, l);
  97     }
  98 
  99     /**
 100      * Returns an array of all the change listeners
 101      * registered on this <code>DefaultSingleSelectionModel</code>.
 102      *
 103      * @return all of this model's <code>ChangeListener</code>s
 104      *         or an empty
 105      *         array if no change listeners are currently registered
 106      *
 107      * @see #addChangeListener
 108      * @see #removeChangeListener
 109      *
 110      * @since 1.4
 111      */
 112     public ChangeListener[] getChangeListeners() {
 113         return (ChangeListener[])listenerList.getListeners(
 114                 ChangeListener.class);
 115     }
 116 
 117     /**
 118      * Notifies all listeners that have registered interest for
 119      * notification on this event type.  The event instance
 120      * is created lazily.
 121      * @see EventListenerList
 122      */
 123     protected void fireStateChanged() {
 124         // Guaranteed to return a non-null array
 125         Object[] listeners = listenerList.getListenerList();
 126         // Process the listeners last to first, notifying
 127         // those that are interested in this event
 128         for (int i = listeners.length-2; i>=0; i-=2) {
 129             if (listeners[i]==ChangeListener.class) {
 130                 // Lazily create the event:
 131                 if (changeEvent == null)
 132                     changeEvent = new ChangeEvent(this);
 133                 ((ChangeListener)listeners[i+1]).stateChanged(changeEvent);
 134             }




  93      * Removes a <code>ChangeListener</code> from the button.
  94      */
  95     public void removeChangeListener(ChangeListener l) {
  96         listenerList.remove(ChangeListener.class, l);
  97     }
  98 
  99     /**
 100      * Returns an array of all the change listeners
 101      * registered on this <code>DefaultSingleSelectionModel</code>.
 102      *
 103      * @return all of this model's <code>ChangeListener</code>s
 104      *         or an empty
 105      *         array if no change listeners are currently registered
 106      *
 107      * @see #addChangeListener
 108      * @see #removeChangeListener
 109      *
 110      * @since 1.4
 111      */
 112     public ChangeListener[] getChangeListeners() {
 113         return listenerList.getListeners(ChangeListener.class);

 114     }
 115 
 116     /**
 117      * Notifies all listeners that have registered interest for
 118      * notification on this event type.  The event instance
 119      * is created lazily.
 120      * @see EventListenerList
 121      */
 122     protected void fireStateChanged() {
 123         // Guaranteed to return a non-null array
 124         Object[] listeners = listenerList.getListenerList();
 125         // Process the listeners last to first, notifying
 126         // those that are interested in this event
 127         for (int i = listeners.length-2; i>=0; i-=2) {
 128             if (listeners[i]==ChangeListener.class) {
 129                 // Lazily create the event:
 130                 if (changeEvent == null)
 131                     changeEvent = new ChangeEvent(this);
 132                 ((ChangeListener)listeners[i+1]).stateChanged(changeEvent);
 133             }


< prev index next >