Java Reference
In-Depth Information
When the worker's finished rolling dice, the propertyChange() method of DiceRoller
will receive a property change event.
This method receives the result of doInBackground() by calling the worker's get()
method (line 81), which must be cast to an integer array:
int[] result = (int[] worker.get();
The application is shown in Figure 14.5.
FIGURE 14.5
Tabulating dice-roll
results prepared
by SwingWorker .
Summary
The topics covered today are two of many capabilities that make Java suitable for appli-
cation development: browser-based program deployment and Swing performance
improvements through the use of threads. Java Web Start blurs the distinction between
applications and applets.
With Web Start, users no longer need to run an installation program to set up a Java
application and the interpreter that executes the class. Web Start takes care of this auto-
matically, after the user's browser has been equipped to use the Java Runtime
Environment.
Support for Web Start is offered through the Java Network Launching Protocol (JNLP),
an XML file format used to define and set up Java Web Start.
The SwingWorker class improves Swing application performance by putting a time-con-
suming task in its own thread. All of the work required to start and stop the thread is
handled by the class behind the scenes.
When you create a subclass of SwingWorker , you can focus on the task that must be per-
formed.
14
 
Search WWH ::




Custom Search