java.awt

Class SplashScreen


  • public final class SplashScreen
    extends Object
    The splash screen can be displayed at application startup, before the Java Virtual Machine (JVM) starts. The splash screen is displayed as an undecorated window containing an image. You can use GIF, JPEG, or PNG files for the image. Animation is supported for the GIF format, while transparency is supported both for GIF and PNG. The window is positioned at the center of the screen. The position on multi-monitor systems is not specified. It is platform and implementation dependent. The splash screen window is closed automatically as soon as the first window is displayed by Swing/AWT (may be also closed manually using the Java API, see below).

    If your application is packaged in a jar file, you can use the "SplashScreen-Image" option in a manifest file to show a splash screen. Place the image in the jar archive and specify the path in the option. The path should not have a leading slash.
    For example, in the manifest.mf file:

     Manifest-Version: 1.0
     Main-Class: Test
     SplashScreen-Image: filename.gif
     

    If the Java implementation provides the command-line interface and you run your application by using the command line or a shortcut, use the Java application launcher option to show a splash screen. The Oracle reference implementation allows you to specify the splash screen image location with the -splash: option.
    For example:

     java -splash:filename.gif Test
     
    The command line interface has higher precedence over the manifest setting.

    The splash screen will be displayed as faithfully as possible to present the whole splash screen image given the limitations of the target platform and display.

    It is implied that the specified image is presented on the screen "as is", i.e. preserving the exact color values as specified in the image file. Under certain circumstances, though, the presented image may differ, e.g. when applying color dithering to present a 32 bits per pixel (bpp) image on a 16 or 8 bpp screen. The native platform display configuration may also affect the colors of the displayed image (e.g. color profiles, etc.)

    The SplashScreen class provides the API for controlling the splash screen. This class may be used to close the splash screen, change the splash screen image, get the splash screen native window position/size, and paint in the splash screen. It cannot be used to create the splash screen. You should use the options provided by the Java implementation for that.

    This class cannot be instantiated. Only a single instance of this class can exist, and it may be obtained by using the getSplashScreen() static method. In case the splash screen has not been created at application startup via the command line or manifest file option, the getSplashScreen method returns null.

    Since:
    1.6
    • Method Detail

      • getSplashScreen

        public static SplashScreen getSplashScreen()
        Returns the SplashScreen object used for Java startup splash screen control on systems that support display.
        Returns:
        the SplashScreen instance, or null if there is none or it has already been closed
        Throws:
        UnsupportedOperationException - if the splash screen feature is not supported by the current toolkit
        HeadlessException - if GraphicsEnvironment.isHeadless() returns true
      • setImageURL

        public void setImageURL(URL imageURL)
                         throws NullPointerException,
                                IOException,
                                IllegalStateException
        Changes the splash screen image. The new image is loaded from the specified URL; GIF, JPEG and PNG image formats are supported. The method returns after the image has finished loading and the window has been updated. The splash screen window is resized according to the size of the image and is centered on the screen.
        Parameters:
        imageURL - the non-null URL for the new splash screen image
        Throws:
        NullPointerException - if imageURL is null
        IOException - if there was an error while loading the image
        IllegalStateException - if the splash screen has already been closed
      • getImageURL

        public URL getImageURL()
                        throws IllegalStateException
        Returns the current splash screen image.
        Returns:
        URL for the current splash screen image file
        Throws:
        IllegalStateException - if the splash screen has already been closed
      • getBounds

        public Rectangle getBounds()
                            throws IllegalStateException
        Returns the bounds of the splash screen window as a Rectangle. This may be useful if, for example, you want to replace the splash screen with your window at the same location.

        You cannot control the size or position of the splash screen. The splash screen size is adjusted automatically when the image changes.

        The image may contain transparent areas, and thus the reported bounds may be larger than the visible splash screen image on the screen.

        Returns:
        a Rectangle containing the splash screen bounds
        Throws:
        IllegalStateException - if the splash screen has already been closed
      • getSize

        public Dimension getSize()
                          throws IllegalStateException
        Returns the size of the splash screen window as a Dimension. This may be useful if, for example, you want to draw on the splash screen overlay surface.

        You cannot control the size or position of the splash screen. The splash screen size is adjusted automatically when the image changes.

        The image may contain transparent areas, and thus the reported size may be larger than the visible splash screen image on the screen.

        Returns:
        a Dimension object indicating the splash screen size
        Throws:
        IllegalStateException - if the splash screen has already been closed
      • createGraphics

        public Graphics2D createGraphics()
                                  throws IllegalStateException
        Creates a graphics context (as a Graphics2D object) for the splash screen overlay image, which allows you to draw over the splash screen. Note that you do not draw on the main image but on the image that is displayed over the main image using alpha blending. Also note that drawing on the overlay image does not necessarily update the contents of splash screen window. You should call update() on the SplashScreen when you want the splash screen to be updated immediately.

        The pixel (0, 0) in the coordinate space of the graphics context corresponds to the origin of the splash screen native window bounds (see getBounds()).

        Returns:
        graphics context for the splash screen overlay surface
        Throws:
        IllegalStateException - if the splash screen has already been closed
      • update

        public void update()
                    throws IllegalStateException
        Updates the splash window with current contents of the overlay image.
        Throws:
        IllegalStateException - if the overlay image does not exist; for example, if createGraphics has never been called, or if the splash screen has already been closed
      • close

        public void close()
                   throws IllegalStateException
        Hides the splash screen, closes the window, and releases all associated resources.
        Throws:
        IllegalStateException - if the splash screen has already been closed
      • isVisible

        public boolean isVisible()
        Determines whether the splash screen is visible. The splash screen may be hidden using close(), it is also hidden automatically when the first AWT/Swing window is made visible.

        Note that the native platform may delay presenting the splash screen native window on the screen. The return value of true for this method only guarantees that the conditions to hide the splash screen window have not occurred yet.

        Returns:
        true if the splash screen is visible (has not been closed yet), false otherwise

Nederlandse vertaling

U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.

Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.

Bij voorbaat dank.

Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-java/awt/splashscreen.html

De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.

Referenties

  1. Bekijk - html-document Taal van het document:fr Manuel PHP : https://docs.oracle.com

Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.

Inhoudsopgave Haut