1

我有一个名为 PollFrame 的类,它在名为 PollFrame.java 的文件中扩展了 JFrame。PollFrame 包含一个表单。我有一个小程序,里面有一个按钮。单击按钮时,我希望显示 PollFrame。我将 ActionPerformed 设置为:

Pollframe poll = new PollFrame(); // This initializes the form
poll.setVisible(true);

但是,当我单击按钮时,出现以下错误:

Exception in thread "AWT-EventQueue-2" java.security.AccessControlException: access denied (java.lang.RuntimePermission exitVM.0)
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkExit(Unknown Source)
    at javax.swing.JFrame.setDefaultCloseOperation(Unknown Source)
    at com.org.pollFrame.initComponents(pollFrame.java:54)
    at com.org.pollFrame.<init>(pollFrame.java:11)
    at com.org.EmployeeApplet.requestRoomActionPerformed(EmployeeApplet.java:216)
    at com.org.EmployeeApplet.access$300(EmployeeApplet.java:7)
    at com.org.EmployeeApplet$4.actionPerformed(EmployeeApplet.java:71)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

我从上面的错误中猜测,禁止从小程序调用另一个类文件。有什么方法可以从小程序显示 PollFrame 吗?

4

2 回答 2

2

似乎您正在调用setDefaultCloseOperation()您的 JFrame,这会引发安全异常

您可以明确地从小程序调用另一个类,但某些操作受到限制,例如。您无法打开本地文件,打开与其他机器的连接...

于 2010-04-17T10:19:44.970 回答
1

我有一个名为 PollFrame 的类,它在名为 PollFrame.java 的文件中扩展了 JFrame。PollFrame 包含一个表单。我有一个小程序,里面有一个按钮。单击按钮时,我希望显示 PollFrame。

这是一个班轮:

applet.showDocument("PollFrame.jnlp", "_blank");

启动的框架PollFrame.jnlp将能够在仍处于沙盒状态时调用它喜欢的任何默认关闭操作,因为它将有一个单独的 VM。要“始终处于领先地位”,它需要被信任(然后与所有其他旨在始终处于领先地位的应用程序进行斗争)。

于 2011-09-16T07:50:17.743 回答