Java Reference
In-Depth Information
L ISTING 7.6 Continued
}
String[] a = new String[result.size()];
result.toArray(a);
return a;
}
/**
* writes on the applet's message area
*/
private void printMessage(String msg){
messagesArea.append(msg+”\n”);
7
}
/**
* main method
*/
static public void main(String[] args) {
System.getProperties().put(“resources”,”setup\\res\\a.jar”);
System.getProperties().put(“destination”,”c:\\appzz”);
System.getProperties().put(“appname”,”MegaAppz 1.0”);
InstallerApplet a = new InstallerApplet();
a.isStandalone = true;
JFrame f = new JFrame(“Test Frame”);
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
a.init();
f.getContentPane().add(a);
f.setSize(400,300);
f.setVisible(true);
a.start();
}
}
Note the code used to allow the applet to run as an application as well, especially the main
method beginning at line 157 of Listing 7.6. The parameters and the getCodebase method (line
119 of Listing 7.6) supply directory change according to whether the InstallerApplet is run
as an applet or an application (method getParameter at line 22 of Listing 7.6).
Ascreenshot from the installer applet launched as an application is shown in Figure 7.7.
Search WWH ::




Custom Search