< prev index next >

src/java.desktop/share/classes/javax/swing/RepaintManager.java

Print this page


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


1797             }
1798             return null;
1799         }
1800     }
1801 
1802     private class DoubleBufferInfo {
1803         public Image image;
1804         public Dimension size;
1805         public boolean needsReset = false;
1806     }
1807 
1808 
1809     /**
1810      * Listener installed to detect display changes. When display changes,
1811      * schedules a callback to notify all RepaintManagers of the display
1812      * changes. Only one DisplayChangedHandler is ever installed. The
1813      * singleton instance will schedule notification for all AppContexts.
1814      */
1815     private static final class DisplayChangedHandler implements
1816                                              DisplayChangedListener {
1817         // Empty non private constructor was added because access to this
1818         // class shouldn't be generated by the compiler using synthetic
1819         // accessor method
1820         DisplayChangedHandler() {
1821         }
1822 
1823         public void displayChanged() {
1824             scheduleDisplayChanges();
1825         }
1826 
1827         public void paletteChanged() {
1828         }
1829 
1830         private static void scheduleDisplayChanges() {
1831             // To avoid threading problems, we notify each RepaintManager
1832             // on the thread it was created on.
1833             for (AppContext context : AppContext.getAppContexts()) {
1834                 synchronized(context) {
1835                     if (!context.isDisposed()) {
1836                         EventQueue eventQueue = (EventQueue)context.get(
1837                             AppContext.EVENT_QUEUE_KEY);
1838                         if (eventQueue != null) {
1839                             eventQueue.postEvent(new InvocationEvent(
1840                                 Toolkit.getDefaultToolkit(),
1841                                 new DisplayChangedRunnable()));
1842                         }


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


1797             }
1798             return null;
1799         }
1800     }
1801 
1802     private class DoubleBufferInfo {
1803         public Image image;
1804         public Dimension size;
1805         public boolean needsReset = false;
1806     }
1807 
1808 
1809     /**
1810      * Listener installed to detect display changes. When display changes,
1811      * schedules a callback to notify all RepaintManagers of the display
1812      * changes. Only one DisplayChangedHandler is ever installed. The
1813      * singleton instance will schedule notification for all AppContexts.
1814      */
1815     private static final class DisplayChangedHandler implements
1816                                              DisplayChangedListener {






1817         public void displayChanged() {
1818             scheduleDisplayChanges();
1819         }
1820 
1821         public void paletteChanged() {
1822         }
1823 
1824         private static void scheduleDisplayChanges() {
1825             // To avoid threading problems, we notify each RepaintManager
1826             // on the thread it was created on.
1827             for (AppContext context : AppContext.getAppContexts()) {
1828                 synchronized(context) {
1829                     if (!context.isDisposed()) {
1830                         EventQueue eventQueue = (EventQueue)context.get(
1831                             AppContext.EVENT_QUEUE_KEY);
1832                         if (eventQueue != null) {
1833                             eventQueue.postEvent(new InvocationEvent(
1834                                 Toolkit.getDefaultToolkit(),
1835                                 new DisplayChangedRunnable()));
1836                         }


< prev index next >