148.176.233.103 writes:
Hi, hope someone can help.
Is it possible to spawn a new window (say a JFrame) from an applet? I wish to create a new desktop separate from the browser window, if possible, as with menus and internal frames, an applet would get quite crowded in a browser.
Cheers! Email me if you like.
Chris.
Chris Conroy
152.174.210.169 writes:
It sure is. In JDK1.1 though you had to create a subclass of java.awt.Frame and then instanciate that. That may apply to SWING objects as well. So, create a MyJFrame which extends JFrame and then use the MyJFrame in your applet. I forgot why that little trick was necessary. May have been a bug or something ...
MikeD
148.176.232.102 writes:
Mike,
THanks for your reply. I've tried this, but it doesn't seem to do the business. With a CommerApplet file extending JApplet and simply instantiating CommerGUI (which itself extends JFrame), I get the following error message in my IE4.72 Java console:
java.lang.IllegalArgumentException: adding a window to a container
at java/awt/Container.addImpl
at java/awt/Container.add
at CommerApplet.init
at com/ms/applet/AppletPanel.securedCall0
at com/ms/applet/AppletPanel.securedCall
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.run
at java/lang/Thread.run
Any ideas as to what I'm doing wrong? If you have any examples of spawning a separate frame, I'd be grateful.
Chris.
CJC
152.169.251.140 writes:
Here is code from a clock applet I wrote which had the clock in it's own Window separate from the browser. It was my OtherTimeApplet which showed the user the time in other time zones. I wrote it for someone in Europe that needed it, since I thought it'd be an interesting little project to pursue. It looked fine on Netscape Navigator, but, unfortunately, I wasn't able to get it running on Microsoft Internet Explorer, but I suspect that it would work if I use Swing components.
import OtherTimeFrame;
class OtherTimeApplet
{
private static OtherTimeFrame frameClock;
.
.
.
public void start
(
)
{
frameClock = new OtherTimeFrame();
frameClock.setResizable(false);
frameClock.toFront();
frameClock.show();
}
public void stop
(
)
{
frameClock.dispose();
destroy();
}
.
.
.
}
MikeD