< prev index next >

src/java.desktop/share/classes/sun/swing/plaf/DesktopProperty.java

Print this page


   1 /*
   2  * Copyright (c) 2001, 2017, 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


  94     /**
  95      * Sets whether or not an updateUI call is pending.
  96      */
  97     private static synchronized void setUpdatePending(boolean update) {
  98         AppContext.getAppContext()
  99                 .put(DESKTOP_PROPERTY_UPDATE_PENDING_KEY, update);
 100     }
 101 
 102     /**
 103      * Returns true if a UI update is pending.
 104      */
 105     private static synchronized boolean isUpdatePending() {
 106         return Boolean.TRUE.equals(AppContext.getAppContext()
 107                 .get(DESKTOP_PROPERTY_UPDATE_PENDING_KEY));
 108     }
 109 
 110     /**
 111      * Updates the UIs of all the known Frames.
 112      */
 113     protected void updateAllUIs() {
 114         Frame appFrames[] = Frame.getFrames();
 115         for (Frame appFrame : appFrames) {
 116             updateWindowUI(appFrame);
 117         }
 118     }
 119 
 120     /**
 121      * Updates the UI of the passed in window and all its children.
 122      */
 123     private static void updateWindowUI(Window window) {
 124         SwingUtilities.updateComponentTreeUI(window);
 125         Window ownedWins[] = window.getOwnedWindows();
 126         for (Window ownedWin : ownedWins) {
 127             updateWindowUI(ownedWin);
 128         }
 129     }
 130 
 131 
 132     /**
 133      * Creates a DesktopProperty.
 134      *
 135      * @param key Key used in looking up desktop value.
 136      * @param fallback Value used if desktop property is null.
 137      */
 138     public DesktopProperty(String key, Object fallback) {
 139         this.key = key;
 140         this.fallback = fallback;
 141         // The only sure fire way to clear our references is to create a
 142         // Thread and wait for a reference to be added to the queue.
 143         // Because it is so rare that you will actually change the look
 144         // and feel, this stepped is forgoed and a middle ground of
 145         // flushing references from the constructor is instead done.


   1 /*
   2  * Copyright (c) 2001, 2018, 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


  94     /**
  95      * Sets whether or not an updateUI call is pending.
  96      */
  97     private static synchronized void setUpdatePending(boolean update) {
  98         AppContext.getAppContext()
  99                 .put(DESKTOP_PROPERTY_UPDATE_PENDING_KEY, update);
 100     }
 101 
 102     /**
 103      * Returns true if a UI update is pending.
 104      */
 105     private static synchronized boolean isUpdatePending() {
 106         return Boolean.TRUE.equals(AppContext.getAppContext()
 107                 .get(DESKTOP_PROPERTY_UPDATE_PENDING_KEY));
 108     }
 109 
 110     /**
 111      * Updates the UIs of all the known Frames.
 112      */
 113     protected void updateAllUIs() {
 114         Frame[] appFrames = Frame.getFrames();
 115         for (Frame appFrame : appFrames) {
 116             updateWindowUI(appFrame);
 117         }
 118     }
 119 
 120     /**
 121      * Updates the UI of the passed in window and all its children.
 122      */
 123     private static void updateWindowUI(Window window) {
 124         SwingUtilities.updateComponentTreeUI(window);
 125         Window[] ownedWins = window.getOwnedWindows();
 126         for (Window ownedWin : ownedWins) {
 127             updateWindowUI(ownedWin);
 128         }
 129     }
 130 
 131 
 132     /**
 133      * Creates a DesktopProperty.
 134      *
 135      * @param key Key used in looking up desktop value.
 136      * @param fallback Value used if desktop property is null.
 137      */
 138     public DesktopProperty(String key, Object fallback) {
 139         this.key = key;
 140         this.fallback = fallback;
 141         // The only sure fire way to clear our references is to create a
 142         // Thread and wait for a reference to be added to the queue.
 143         // Because it is so rare that you will actually change the look
 144         // and feel, this stepped is forgoed and a middle ground of
 145         // flushing references from the constructor is instead done.


< prev index next >