You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Applets<br />
}<br />
Foo applet = new Foo();<br />
applet.start();<br />
add(applet, "Center");<br />
//...<br />
main()is function of course, not constructor<br />
--<br />
Alex<br />
Q: Is it possible to run a java applet in a dos window (win98 se)?<br />
Answer: No. A dos window is a character device. You can use the applet viewer program that comes<br />
with the JDK though.<br />
--<br />
Mike<br />
Q: Is there a simple way to tell if a PC online or not from within an applet?<br />
Answer: Not without either server-side support or signing the applet, since applets are not allowed to<br />
connect to other hosts than the one they are downloaded from. Best approach, I suppose, would be to<br />
ping the target from the server.<br />
However, this is not quite full proof because of firewalling: my pc, for example, will not answer to<br />
pings.<br />
--<br />
Michiel<br />
Q: Is it possible to close browser from applet?<br />
Answer: Yes, use this (tested):<br />
//////////////////////////////////////////////////////<br />
import java.applet.Applet;<br />
import java.awt.*;<br />
import java.awt.event.*;<br />
import netscape.javascript.JSObject;<br />
class CloseApplet extends Applet<br />
implements ActionListener{<br />
protected Button closeButton = null;<br />
protected JSObject win = null;<br />
public void init(){<br />
this.win = JSObject.getWindow(this);<br />
this.closeButton = new Button("Close Browser Window");<br />
this.add(this.closeButton);<br />
this.closeButton.addActionListener(this);<br />
} // ends init(void)<br />
public void actionPerformed(ActionEvent ae){<br />
this.win.eval("self.close();");<br />
}<br />
} // ends class CloseApplet<br />
file:///F|/350_t/350_tips/applets.htm (8 of 10) [2002-02-27 21:17:49]