< prev index next >

src/java.desktop/share/classes/sun/awt/AppContext.java

Print this page




 173 
 174     private static class GetAppContextLock {};
 175     private final static Object getAppContextLock = new GetAppContextLock();
 176 
 177     /*
 178      * The hash map associated with this AppContext.  A private delegate
 179      * is used instead of subclassing HashMap so as to avoid all of
 180      * HashMap's potentially risky methods, such as clear(), elements(),
 181      * putAll(), etc.
 182      */
 183     private final Map<Object, Object> table = new HashMap<>();
 184 
 185     private final ThreadGroup threadGroup;
 186 
 187     /**
 188      * If any <code>PropertyChangeListeners</code> have been registered,
 189      * the <code>changeSupport</code> field describes them.
 190      *
 191      * @see #addPropertyChangeListener
 192      * @see #removePropertyChangeListener
 193      * @see #firePropertyChange
 194      */
 195     private PropertyChangeSupport changeSupport = null;
 196 
 197     public static final String DISPOSED_PROPERTY_NAME = "disposed";
 198     public static final String GUI_DISPOSED = "guidisposed";
 199 
 200     private enum State {
 201         VALID,
 202         BEING_DISPOSED,
 203         DISPOSED
 204     };
 205 
 206     private volatile State state = State.VALID;
 207 
 208     public boolean isDisposed() {
 209         return state == State.DISPOSED;
 210     }
 211 
 212     /*
 213      * The total number of AppContexts, system-wide.  This number is


 792             return;
 793         }
 794         if (changeSupport == null) {
 795             changeSupport = new PropertyChangeSupport(this);
 796         }
 797         changeSupport.addPropertyChangeListener(propertyName, listener);
 798     }
 799 
 800     /**
 801      * Removes a PropertyChangeListener from the listener list for a specific
 802      * property. This method should be used to remove PropertyChangeListeners
 803      * that were registered for a specific bound property.
 804      * <p>
 805      * If listener is null, no exception is thrown and no action is performed.
 806      *
 807      * @param propertyName a valid property name
 808      * @param listener the PropertyChangeListener to be removed
 809      *
 810      * @see #addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
 811      * @see #getPropertyChangeListeners(java.lang.String)
 812      * @see #removePropertyChangeListener(java.beans.PropertyChangeListener)
 813      */
 814     public synchronized void removePropertyChangeListener(
 815                              String propertyName,
 816                              PropertyChangeListener listener) {
 817         if (listener == null || changeSupport == null) {
 818             return;
 819         }
 820         changeSupport.removePropertyChangeListener(propertyName, listener);
 821     }
 822 
 823     /**
 824      * Returns an array of all the listeners which have been associated
 825      * with the named property.
 826      *
 827      * @return all of the <code>PropertyChangeListeners</code> associated with
 828      *         the named property or an empty array if no listeners have
 829      *         been added
 830      *
 831      * @see #addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
 832      * @see #removePropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)




 173 
 174     private static class GetAppContextLock {};
 175     private final static Object getAppContextLock = new GetAppContextLock();
 176 
 177     /*
 178      * The hash map associated with this AppContext.  A private delegate
 179      * is used instead of subclassing HashMap so as to avoid all of
 180      * HashMap's potentially risky methods, such as clear(), elements(),
 181      * putAll(), etc.
 182      */
 183     private final Map<Object, Object> table = new HashMap<>();
 184 
 185     private final ThreadGroup threadGroup;
 186 
 187     /**
 188      * If any <code>PropertyChangeListeners</code> have been registered,
 189      * the <code>changeSupport</code> field describes them.
 190      *
 191      * @see #addPropertyChangeListener
 192      * @see #removePropertyChangeListener
 193      * @see PropertyChangeSupport#firePropertyChange
 194      */
 195     private PropertyChangeSupport changeSupport = null;
 196 
 197     public static final String DISPOSED_PROPERTY_NAME = "disposed";
 198     public static final String GUI_DISPOSED = "guidisposed";
 199 
 200     private enum State {
 201         VALID,
 202         BEING_DISPOSED,
 203         DISPOSED
 204     };
 205 
 206     private volatile State state = State.VALID;
 207 
 208     public boolean isDisposed() {
 209         return state == State.DISPOSED;
 210     }
 211 
 212     /*
 213      * The total number of AppContexts, system-wide.  This number is


 792             return;
 793         }
 794         if (changeSupport == null) {
 795             changeSupport = new PropertyChangeSupport(this);
 796         }
 797         changeSupport.addPropertyChangeListener(propertyName, listener);
 798     }
 799 
 800     /**
 801      * Removes a PropertyChangeListener from the listener list for a specific
 802      * property. This method should be used to remove PropertyChangeListeners
 803      * that were registered for a specific bound property.
 804      * <p>
 805      * If listener is null, no exception is thrown and no action is performed.
 806      *
 807      * @param propertyName a valid property name
 808      * @param listener the PropertyChangeListener to be removed
 809      *
 810      * @see #addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
 811      * @see #getPropertyChangeListeners(java.lang.String)
 812      * @see PropertyChangeSupport#removePropertyChangeListener(java.beans.PropertyChangeListener)
 813      */
 814     public synchronized void removePropertyChangeListener(
 815                              String propertyName,
 816                              PropertyChangeListener listener) {
 817         if (listener == null || changeSupport == null) {
 818             return;
 819         }
 820         changeSupport.removePropertyChangeListener(propertyName, listener);
 821     }
 822 
 823     /**
 824      * Returns an array of all the listeners which have been associated
 825      * with the named property.
 826      *
 827      * @return all of the <code>PropertyChangeListeners</code> associated with
 828      *         the named property or an empty array if no listeners have
 829      *         been added
 830      *
 831      * @see #addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
 832      * @see #removePropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)


< prev index next >