/* GeoGebra - Dynamic Mathematics for Everyone http://www.geogebra.org This file is part of GeoGebra. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. */ package geogebra; /* * Copyright (c) 1999-2003 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland * All rights reserved. * * This material is provided "as is", with absolutely no warranty expressed * or implied. Any use is at your own risk. * * Permission to use or copy this software is hereby granted without fee, * provided this copyright notice is retained on all copies. */ import java.awt.Color; import java.awt.EventQueue; import java.awt.Frame; import java.awt.Graphics; import java.awt.Image; import java.awt.MediaTracker; import java.awt.Window; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; /** * Splash Window to show an image during startup of an application.
* * Usage: *
* // open the splash window * Frame splashOwner = SplashWindow.splash(anImage); * * // start the application * // ... * * // dispose the splash window by disposing the frame that owns the window. * splashOwner.dispose(); ** *
To use the splash window as an about dialog write this: *
* new SplashWindow( * this, * getToolkit().createImage(getClass().getResource(GeoGebra.SPLASH_STRING)) * ).show(); ** * The splash window disposes itself when the user clicks on it. * * @author Werner Randelshofer, Staldenmattweg 2, Immensee, CH-6405, Switzerland. * @version 1.3 2003-06-01 Revised. */ public class SplashWindow extends Window { /** * */ private static final long serialVersionUID = 1L; private Image splashImage; /** * This attribute indicates whether the method * paint(Graphics) has been called at least once since the * construction of this window.
* This method is useful for startup splashs. * Dispose the return frame to get rid of the splash window.
* * @param splashImage The image to be displayed. * @return Returns the frame that owns the SplashWindow. */ public static Frame splash(Image splashImage) { Frame f = new Frame(); SplashWindow w = new SplashWindow(f, splashImage, false); // Show the window. w.toFront(); w.setVisible(true); // Note: To make sure the user gets a chance to see the // splash window we wait until its paint method has been // called at least by the AWT event dispatcher thread. if (! EventQueue.isDispatchThread()) { synchronized (w) { while (! w.paintCalled) { try { w.wait(); } catch (InterruptedException e) {} } } } return f; } }