public final class SplashScreen extends Object
 如果您的应用程序打包在一个jar文件中,您可以使用清单文件中的“SplashScreen-Image”选项来显示启动画面。 将图像放在jar存档中并指定选项中的路径。 该路径不应该有一个主要的斜杠。 
 例如,在manifest.mf文件中: 
  Manifest-Version: 1.0
 Main-Class: Test
 SplashScreen-Image: filename.gif  
        如果Java实现提供命令行界面,并且使用命令行或快捷方式运行应用程序,请使用Java应用程序启动程序选项显示启动屏幕。 Oracle参考实现允许您使用-splash:选项指定启动屏幕图像位置。 
 例如: 
  java -splash:filename.gif Test  
       命令行界面的优先级高于清单设置。 
       初始屏幕将尽可能忠实地显示给出目标平台和显示的限制的整个闪屏图像。
这意味着指定的图像按“原样”显示在屏幕上,即保留图像文件中指定的精确颜色值。 然而,在某些情况下,所呈现的图像可能不同,例如,当应用颜色抖动以在16或8 bpp屏幕上呈现每像素32位(bpp)图像时。 本机平台显示配置还可能影响显示图像的颜色(例如颜色配置文件等)
 SplashScreen类提供了控制启动画面的API。 此类可用于关闭启动屏幕,更改启动屏幕图像,获取启动屏幕本机窗口位置/大小,并在启动屏幕中绘制。 它不能用于创建闪屏。 您应该使用Java实现提供的选项。 
 这个类不能被实例化。 只有这个类的一个实例可以存在,并且可以通过使用getSplashScreen()静态方法获得。 如果通过命令行或清单文件选项在应用程序启动时尚未创建启动屏幕,则getSplashScreen方法返回null 。 
| Modifier and Type | Method and Description | 
|---|---|
| void | close()
              隐藏启动屏幕,关闭窗口,并释放所有关联的资源。 
             | 
| Graphics2D | createGraphics() 
             为启动屏幕叠加图像创建图形上下文(作为 Graphics2D对象),允许您绘制闪屏。 | 
| Rectangle | getBounds() 
             将启动屏幕窗口的边界返回为 Rectangle。 | 
| URL | getImageURL()
              返回当前的闪屏图像。 
             | 
| Dimension | getSize() 
             以 Dimension返回闪屏的大小。 | 
| static SplashScreen | getSplashScreen()
              返回在支持显示的系统上用于Java启动启动画面控件的 
              SplashScreen对象。 | 
| boolean | isVisible()
              确定启动屏幕是否可见。 
             | 
| void | setImageURL(URL imageURL)
              更改启动屏幕图像。 
             | 
| void | update()
              使用覆盖图像的当前内容更新启动窗口。 
             | 
public static SplashScreen getSplashScreen()
SplashScreen对象。 
          SplashScreen实例,或null如果没有或已经关闭 
           UnsupportedOperationException - 如果当前工具包不支持启动屏幕功能 
           HeadlessException - 如果 
            GraphicsEnvironment.isHeadless()返回true 
           public void setImageURL(URL imageURL) throws NullPointerException, IOException, IllegalStateException
imageURL - 新的启动屏幕图像的非 
            null网址 
           NullPointerException - 如果 
            imageURL是 
            null 
           IOException - 如果在加载图像时出错 
           IllegalStateException - 如果启动画面已经关闭 
           public URL getImageURL() throws IllegalStateException
IllegalStateException - 如果启动画面已经关闭 
           public Rectangle getBounds() throws IllegalStateException
Rectangle返回启动屏幕窗口的边界 。 
           如果您要将窗口替换为同一位置的启动画面,这可能会有用。 
           您无法控制闪屏的大小或位置。 当图像更改时,启动画面尺寸会自动调整。
图像可能包含透明区域,因此报告的边界可能大于屏幕上可见的闪屏图像。
Rectangle包含启动屏幕边界 
           IllegalStateException - 如果启动画面已经关闭 
           public Dimension getSize() throws IllegalStateException
Dimension返回启动屏幕窗口的大小 。 
           如果您想要在闪屏上叠加表面上绘制,这可能很有用。 
           您无法控制闪屏的大小或位置。 当图像更改时,启动画面尺寸会自动调整。
图像可能包含透明区域,因此报告的大小可能大于屏幕上可见的闪屏图像。
Dimension对象,指示启动屏幕大小 
           IllegalStateException - 如果启动画面已经关闭 
           public Graphics2D createGraphics() throws IllegalStateException
Graphics2D对象),允许您绘制闪屏。 
           请注意,您不要绘制主图像,而是使用Alpha混合在主图像上显示的图像上。 
           还要注意,叠加图像上的绘图不一定会更新启动画面窗口的内容。 
           你应该叫update()在SplashScreen当你想启动画面立即更新。 
            图形上下文的坐标空间中的像素(0,0)对应于闪屏本机窗口界限的起点(见getBounds() )。 
IllegalStateException - 启动画面是否已经关闭 
           public void update()
            throws IllegalStateException 
          IllegalStateException - 如果覆盖图像不存在; 
            例如,如果createGraphics从未被调用,或者启动屏幕已经关闭 
           public void close()
           throws IllegalStateException 
          IllegalStateException - 如果启动画面已经关闭 
           public boolean isVisible()
close()隐藏,当第一个AWT / Swing窗口可见时,它也会自动隐藏。 
            请注意,本地平台可能会延迟在屏幕上显示启动屏幕本机窗口。 此方法的返回值为true仅保证隐藏启动屏幕窗口的条件尚未发生。 
 Submit a bug or feature 
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
 Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.