views:

244

answers:

1

Given a JApplet, how do I obtain the JFrame object corresponding to this applet?

JApplet applet = this;
JRootPane rootPane = getRootPane();
Container contentPane = getContentPane();
JFrame jframe = ...; // How do I obtain the JFrame?
+3  A: 

You can create a new JFrame from an Applet. But there is no container like a JFrame surrounding an Applet. The Applet is ths container.

Pierre
IIRC, the plug-in does have an embedded `JFrame`, but this is just an implementation detail. `Applet` is considered the *top-level* container.
Tom Hawtin - tackline