Applets
main()is function of course, not constructor
Alex
Q: Is it possible to run a java applet in a dos window (win98 se)?
Answer: No. A dos window is a character device. You can use the applet viewer program that comes
with the JDK though.
Mike
Q: Is there a simple way to tell if a PC online or not from within an applet?
Answer: Not without either server side support or signing the applet, since applets are not allowed to
connect to other hosts than the one they are downloaded from. Best approach, I suppose, would be to
ping the target from the server.
However, this is not quite full proof because of firewalling: my pc, for example, will not answer to
pings.
Michiel
Q: Is it possible to close browser from applet?
Answer: Yes, use this (tested):
//////////////////////////////////////////////////////
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import netscape.javascript.JSObject;
class CloseApplet extends Applet
implements ActionListener{
protected Button closeButton = null;
protected JSObject win = null;
public void init(){
this.win = JSObject.getWindow(this);
this.closeButton = new Button("Close Browser Window");
this.add(this.closeButton);
this.closeButton.addActionListener(this);
} // ends init(void)
public void actionPerformed(ActionEvent ae){
this.win.eval("self.close();");
}
} // ends class CloseApplet
//////////////////////////////////////////////////////
and the HTML needs to have MAYSCRIPT enabled.
//////////////////////////////////////////////////////
file:///F|/a_jsite/350_tips/applets.htm (8 of 9) [2001 07 08 11:24:47]
footer
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved