文档

Java™ 教程-Java Tutorials 中文版
自定义加载屏幕
Trail: Deployment
Lesson: Deployment In-Depth
Section: Deployment Toolkit
Subsection: Deploying an Applet

自定义加载屏幕

A default loading screen is displayed when an applet is being loaded in the web page. You can display a customized splash screen by specifying the following parameters when you deploy the applet:

The splash screen can display a static image or an animated gif.

The code snippet from AppletPage.html shows how to customize the splash screen to display an animation of the Duke, the Java mascot.

<script src="https://www.java.com/js/deployJava.js"></script>
<script> 
  var attributes = {code:'SwingSet2Applet.class',
      archive:'SwingSet2.jar', width:695, height:525} ; 
    <!-- customize splash screen display options -->
  var parameters = {jnlp_href: 'SwingSet2.jnlp', 
                    image: 'dukeanimated.gif', 
                    boxbgcolor: 'cyan', 
                    boxborder: 'true', 
                    centerimage: 'true'   
                    }; 
  deployJava.runApplet(attributes, parameters, '1.6'); 
</script>

Open AppletPage.html in a browser to view the splash screen when the SwingSet2 Demo applet is loaded. If you've clicked this link before and viewed the SwingSet2 Demo applet, make sure to clear your cache using the Java Control Panel. You may not see the splash screen if the applet loads quickly.


注意: If you don't see the applet running, you need to install at least the Java SE Development Kit (JDK) 6 update 10 release.

注意: If you don't see the example running, you might need to enable the JavaScript interpreter in your browser so that the Deployment Toolkit script can function properly.

See the Displaying a Customized Loading Progress Indicator topic for information about displaying a customized loading progress indicator when the applet's resources are being downloaded.

Download source codefor the Customizing Splash Screen example to experiment further.


Previous page: Deploying an Applet
Next page: Embedding JNLP File in Applet Tag