< prev index next >

src/java.desktop/share/classes/java/awt/SplashScreen.java

Print this page
rev 55657 : 8227587: Add internal privileged System.loadLibrary
Reviewed-by: rriggs
   1 /*
   2  * Copyright (c) 2005, 2014, 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


 111     }
 112 
 113     /**
 114      * Returns the {@code SplashScreen} object used for
 115      * Java startup splash screen control on systems that support display.
 116      *
 117      * @throws UnsupportedOperationException if the splash screen feature is not
 118      *         supported by the current toolkit
 119      * @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
 120      *         returns true
 121      * @return the {@link SplashScreen} instance, or {@code null} if there is
 122      *         none or it has already been closed
 123      */
 124     public static  SplashScreen getSplashScreen() {
 125         synchronized (SplashScreen.class) {
 126             if (GraphicsEnvironment.isHeadless()) {
 127                 throw new HeadlessException();
 128             }
 129             // SplashScreen class is now a singleton
 130             if (!wasClosed && theInstance == null) {
 131                 java.security.AccessController.doPrivileged(
 132                     new java.security.PrivilegedAction<Void>() {
 133                         public Void run() {
 134                             System.loadLibrary("splashscreen");
 135                             return null;
 136                         }
 137                     });
 138                 long ptr = _getInstance();
 139                 if (ptr != 0 && _isVisible(ptr)) {
 140                     theInstance = new SplashScreen(ptr);
 141                 }
 142             }
 143             return theInstance;
 144         }
 145     }
 146 
 147     /**
 148      * Changes the splash screen image. The new image is loaded from the
 149      * specified URL; GIF, JPEG and PNG image formats are supported.
 150      * The method returns after the image has finished loading and the window
 151      * has been updated.
 152      * The splash screen window is resized according to the size of
 153      * the image and is centered on the screen.
 154      *
 155      * @param imageURL the non-{@code null} URL for the new
 156      *        splash screen image
 157      * @throws NullPointerException if {@code imageURL} is {@code null}


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


 111     }
 112 
 113     /**
 114      * Returns the {@code SplashScreen} object used for
 115      * Java startup splash screen control on systems that support display.
 116      *
 117      * @throws UnsupportedOperationException if the splash screen feature is not
 118      *         supported by the current toolkit
 119      * @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
 120      *         returns true
 121      * @return the {@link SplashScreen} instance, or {@code null} if there is
 122      *         none or it has already been closed
 123      */
 124     public static  SplashScreen getSplashScreen() {
 125         synchronized (SplashScreen.class) {
 126             if (GraphicsEnvironment.isHeadless()) {
 127                 throw new HeadlessException();
 128             }
 129             // SplashScreen class is now a singleton
 130             if (!wasClosed && theInstance == null) {
 131                 jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("splashscreen");






 132                 long ptr = _getInstance();
 133                 if (ptr != 0 && _isVisible(ptr)) {
 134                     theInstance = new SplashScreen(ptr);
 135                 }
 136             }
 137             return theInstance;
 138         }
 139     }
 140 
 141     /**
 142      * Changes the splash screen image. The new image is loaded from the
 143      * specified URL; GIF, JPEG and PNG image formats are supported.
 144      * The method returns after the image has finished loading and the window
 145      * has been updated.
 146      * The splash screen window is resized according to the size of
 147      * the image and is centered on the screen.
 148      *
 149      * @param imageURL the non-{@code null} URL for the new
 150      *        splash screen image
 151      * @throws NullPointerException if {@code imageURL} is {@code null}


< prev index next >