The code to close the applet window isnt implemented in
Main.java and it would be a good idea
//existing code
│ public void offline() {
│ frame.setTitle("jta: offline");
//A kludged one line fix - should detect parameter etc
// and close down gracefully
│ System.exit(0);
│ }
By the why dont you reuse the Applet code from the
Main program, the Applet Panel could be added to the
Frame and I think it would be less code to maintain.
andy@hazlorealidad.com
Logged In: NO
A better fix posted by andy@hazlorealidad.com
- Code copied from Applet.java
public class Main {
private final static int debug = 0;
private final static boolean personalJava = false;
/** holds the last focussed plugin */
private static Plugin focussedPlugin;
/** holds the system clipboard or our own */
private static Clipboard clipboard;
private static String host, port;
//Modificacion por andy
/** close the window (if it exists) after the connection is
lost */
private static boolean disconnectCloseWindow = true;
public static void main(String args[]) {
final Properties options = new Properties();
try {
options.load(Main.class.getResourceAsStream
("/de/mud/jta/default.conf"));
} catch (IOException e) {
System.err.println("jta: cannot load default.conf");
}
String error = parseOptions(options, args);
if (error != null) {
System.err.println(error);
System.err.println("usage: de.mud.jta.Main [-plugins
pluginlist] "
+ "[-addplugin plugin] "
+ "[-config url_or_file] "
+ "[-term id] [host [port]]");
System.exit(0);
}
String cfg = options.getProperty("Main.config");
if (cfg != null)
try {
options.load(new URL(cfg).openStream());
} catch (IOException e) {
try {
options.load(new FileInputStream(cfg));
} catch (Exception fe) {
System.err.println("jta: cannot load " + cfg);
}
}
host = options.getProperty("Socket.host");
port = options.getProperty("Socket.port");
//Modificacion por andy
if (!(new Boolean(options.getProperty
("Applet.disconnect.closeWindow"))
.booleanValue()))
disconnectCloseWindow = false;
final JFrame frame = new JFrame("jta: " + host +
(port.equals("23")?"":" " + port));
// set up the clipboard
try {
clipboard = frame.getToolkit().getSystemClipboard();
} catch (Exception e) {
System.err.println("jta: system clipboard access denied");
System.err.println("jta: copy & paste only within the
JTA");
clipboard = new Clipboard("de.mud.jta.Main");
}
// configure the application and load all plugins
final Common setup = new Common(options);
if (port == null || port.length() == 0) {
if (setup.getPlugins().containsKey("SSH")) {
port = "22";
} else {
port = "23";
}
}
setup.registerPluginListener(new OnlineStatusListener() {
public void online() {
frame.setTitle("jta: " + host + (port.equals("23")?"":" " +
port));
}
public void offline() {
frame.setTitle("jta: offline");
//Modificacion por andy
if (disconnectCloseWindow) System.exit(0);
}
});