Java Reference
In-Depth Information
L ISTING 10.3 Continued
</resources>
<application-desc/>
</jnlp>
In Listing 10.4, a very simple word processor is proposed. Among its commands, the draw
option launches a pop-up dialog box, intended as a plug-in of the main program, for editing
draws. This is a typical scenario for sophisticated applications deployed over the Web, where
secondary functionalities are downloaded only when needed. This way, if the user never uti-
lizes that function, there will be a resource saving, especially during the first-time installation
process.
To obtain this behavior with JNLP technology, just define as lazy the resources that are part of
the secondary programs and be sure to mention those classes only when needed in your main
program.
The LazyEditor Java class representing the main application is shown in Listing 10.4.
L ISTING 10.4 The LazyEditor Class.
package com.marinilli.b2.c10;
import javax.swing.*;
import java.awt.*;
import javax.jnlp.*;
import java.awt.event.*;
/**
* Chapter 10 - A Simple Lazy Text Editor
* @author Mauro Marinilli
* @version 1.0
*/
public class LazyEditor extends JFrame {
ClassLoader loader;
JButton drawButton = new JButton();
JButton otherButton = new JButton();
JButton anotherButton = new JButton();
public LazyEditor() {
loader = getClass().getClassLoader();
getContentPane().setLayout(new BorderLayout());
getContentPane().add(getToolBar(), BorderLayout.NORTH);
getContentPane().add(new TextArea(), BorderLayout.CENTER);
setTitle(“A Lazy Text Editor”);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(WindowEvent e) {
exit();
10
Search WWH ::




Custom Search