1 /*
2 * Copyright (c) 2005, 2013, 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
186 synchronized(SplashScreen.class) {
187 checkVisible();
188 if (!_setImageData(splashPtr, buf)) {
189 throw new IOException("Bad image format or i/o error when loading image");
190 }
191 this.imageURL = imageURL;
192 }
193 }
194
195 private void checkVisible() {
196 if (!isVisible()) {
197 throw new IllegalStateException("no splash screen available");
198 }
199 }
200 /**
201 * Returns the current splash screen image.
202 *
203 * @return URL for the current splash screen image file
204 * @throws IllegalStateException if the splash screen has already been closed
205 */
206 public URL getImageURL() throws IllegalStateException {
207 synchronized (SplashScreen.class) {
208 checkVisible();
209 if (imageURL == null) {
210 try {
211 String fileName = _getImageFileName(splashPtr);
212 String jarName = _getImageJarName(splashPtr);
213 if (fileName != null) {
214 if (jarName != null) {
215 imageURL = new URL("jar:"+(new File(jarName).toURL().toString())+"!/"+fileName);
216 } else {
217 imageURL = new File(fileName).toURL();
218 }
219 }
220 }
221 catch(java.net.MalformedURLException e) {
222 if (log.isLoggable(PlatformLogger.Level.FINE)) {
223 log.fine("MalformedURLException caught in the getImageURL() method", e);
224 }
225 }
|
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
186 synchronized(SplashScreen.class) {
187 checkVisible();
188 if (!_setImageData(splashPtr, buf)) {
189 throw new IOException("Bad image format or i/o error when loading image");
190 }
191 this.imageURL = imageURL;
192 }
193 }
194
195 private void checkVisible() {
196 if (!isVisible()) {
197 throw new IllegalStateException("no splash screen available");
198 }
199 }
200 /**
201 * Returns the current splash screen image.
202 *
203 * @return URL for the current splash screen image file
204 * @throws IllegalStateException if the splash screen has already been closed
205 */
206 @SuppressWarnings("deprecation")
207 public URL getImageURL() throws IllegalStateException {
208 synchronized (SplashScreen.class) {
209 checkVisible();
210 if (imageURL == null) {
211 try {
212 String fileName = _getImageFileName(splashPtr);
213 String jarName = _getImageJarName(splashPtr);
214 if (fileName != null) {
215 if (jarName != null) {
216 imageURL = new URL("jar:"+(new File(jarName).toURL().toString())+"!/"+fileName);
217 } else {
218 imageURL = new File(fileName).toURL();
219 }
220 }
221 }
222 catch(java.net.MalformedURLException e) {
223 if (log.isLoggable(PlatformLogger.Level.FINE)) {
224 log.fine("MalformedURLException caught in the getImageURL() method", e);
225 }
226 }
|