【问题标题】:Obtaining a JFrame from a JApplet从 JApplet 获取 JFrame
【发布时间】:2009-10-03 18:38:58
【问题描述】:

给定一个JApplet,如何获取这个applet对应的JFrame对象?

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

【问题讨论】:

  • 试图在 JFrame 中运行小程序?
  • Omry:不,我有假定访问 JFrame 的代码。我希望这个 JFrame 成为“JApplet 窗口”。创建一个新的 JFrame 将不起作用,因为这将创建一个新窗口。

标签: java swing applet jframe


【解决方案1】:

您可以从 Applet 创建一个新的 JFrame。但是没有像 JFrame 这样围绕 Applet 的容器。 Applet 是个容器。

【讨论】:

  • IIRC,插件确实有一个嵌入的JFrame,但这只是一个实现细节。 Applet 被视为 顶级 容器。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-07-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-21
  • 1970-01-01
相关资源
最近更新 更多