Spec-Zone .ru
спецификации, руководства, описания, API
|
Java Rich Internet applications (RIAs) are downloaded over the internet and displayed to the end user. The speed of the download may vary depending on various criteria such as the size of the RIA JAR file, any external dependencies, and the speed of the internet connection.
When the RIA is being downloaded, by default, the RIA software (Java Plug-in and Java Web Start software) will display the standard progress indicators, such as the spinning Java logo and progress bars. End users may get impatient when confronted with large downloads. With improvements in RIA software technology in the Java SE 6 update 18 and Java SE 6 update 21 releases, you can keep the end user engaged by providing a creative, captivating, and meaningful RIA loading experience. You can customize the RIA loading experience in several ways as described next.
You can also use a combination of the above options to accomodate older versions of the Java Runtime Environment (JRE) software on the client machine.
Note: Certain customization options are specific to applets or to Java Web Start applications. Such cases will be identified in this topic.
This section describes the process by which RIAs are loaded.
RIA software initiates a series of steps to download, validate, and execute a RIA. The RIA loading process can be broadly broken down into the following stages. RIA software provides varying levels of progress-related feedback during these stages.
The simplest way to customize a RIA's loading experience is to provide a splash screen. Specify the image that should be displayed in the splash screen. No changes are required in the RIA itself. RIA software displays the splash screen when the RIA is being loaded and hides it when the RIA's resources have been downloaded and validated. See the following topics for more information:
You can replace the default loading progress indicator with a custom
implementation that provides regular feedback about how the RIA is loading. Don't
feel constrained by rectangular boxes or the use of the Swing
JProgressBar
component. You can develop a customized loading progress indicator
that is meaningful to your RIA or web site. The loading progress indicator can use
visual or non-visual means to
keep the end user interested and engaged while the RIA is loading in the background.
See
Default loading progress indicator for Java Web Start application
Customized loading progress indicator for Java Web Start application
Customized loading progress indicator for the Reversi JavaFX applet (black balls turn white as loading progresses)
The following features enable varied customizations of the loading progress indicator for a RIA that is deployed by using JNLP technology:
JSObject window = JSObject.getWindow(null); window.call("someJavaScriptFunction", args);
The next few paragraphs describe technical details about implementing a loading progress indicator.
javax.jnlp.DownloadServiceListener
InterfaceA loading progress indicator class should implement the
javax.jnlp.DownloadServiceListener
interface.
Specify the following constructors in the loading progress indicator class. The RIA software will invoke the appropriate constructor depending on the capabilities of the JRE software on the client machine. In some cases, RIA software may not instantiate the loading progress indicator class if all resources are up-to-date.
javax.swing.JFrame
object.
java.lang.Object
. The Object
argument can be
typecast to an instance of the java.awt.Container
class. This constructor
is relevant to loading progress indicators for applets.
If the RIA software (in this case, Java Plug-in software) invokes this constructor,
the loading progress indicator UI will be displayed in the applet's container.
java.lang.Object
. The first Object
argument can be
typecast to an instance of the java.awt.Container
class. The second
Object
argument can be
typecast to an instance of the java.applet.AppletStub
class.
If the RIA software (in this case, Java Plug-in software) invokes this constructor,
the loading progress indicator UI will be displayed in the applet's container. The
loading progress indicator can access the java.applet.AppletContext
object to customize the loading progress indicator further.
This constructor is relevant to loading progress indicators for applets.
When specifying the constructor with two parameters, it is better to also specify the single-parameter constructor to accomodate older versions of the client JRE software. The constructor with two parameters is invoked only when the client JRE software version is at least Java SE 6 update 21.
The loading progress indicator class should implement the following methods of the interface to receive and convey the latest progress information.
progress(URL url, String version, long readSoFar,
long total, int overallPercent)
upgradingArchive(java.net.URL url, java.lang.String version,
int patchPercent, int overallPercent)
validating(java.net.URL url, java.lang.String version,
long entry, long total, int overallPercent)
– When the
loading progress indicator class is instantiated, this method
is always invoked with an overallPercent
value of 100.
Update progress information in the loading progress indicator based on the
overallPercent
values received in these methods.
Include the following information in the RIA's Java Network Launch Protocol (JNLP) file to specify a loading progress indicator:
download="progress"
attribute to indicate which JAR file contains
the loading progress indicator class
progress-class
attribute containing fully qualified name of the
loading progress indicator class. This attribute can be defined as a part of the
<applet-desc>
, <application-desc>
, or
<component-desc>
depending on how the RIA and the loading
progress indicator are deployed.
A sample JNLP file for an applet is shown next.
<jnlp spec="1.0+" codebase="" href=""> ... <resources> ... <jar href="MyApplet.jar" main="true" /> <jar href="CustomProgressIndicator.jar" download="progress" /> </resources> <applet-desc name="MyFavoriteApplet" main-class="myAppletPackage.MyFavoriteApplet" progress-class="myCustomProgressPackage.MyCustomProgressIndicator" width="600" height="200"> </applet-desc> ... </jnlp>
RIA software communicates progress information as follows:
progress
,
upgradingArchive
, validating
methods several times with
increasing values of overallPercent
.
main
method instead.
javax.swing.JPanel
object, and add it to the surfaceContainer
object described previously.
After the applet's resources have been completely downloaded, remove the top
level container from the surfaceContainer
object and add it to the
applet itself.
Java Technology |
Copyright © 1993, 2010, Oracle and/or its affiliates. All rights reserved. |