如何显示从applet一个JFrame? [英] how to display a JFrame from an applet?

查看:340
本文介绍了如何显示从applet一个JFrame?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为PollFrame.java文件扩展JFrame的这个类叫做PollFrame。 PollFrame包含窗体。我有一个小程序,其中有一个按钮。当点击该按钮时,我想显示PollFrame。我设置的actionPerformed为:

I have this class called PollFrame that extends JFrame in a file called PollFrame.java . PollFrame contains a form. I have an applet, which has a button in it. When the button is clicked, I want the PollFrame to be displayed. I set the ActionPerformed as:

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

然而,当我按一下按钮,我收到以下错误:

However, when I click the button, I get the following error :

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)

我猜他fromt上面的错误,调用从applet另一个类文件是禁止的。有什么办法,我可以显示来自applet的PollFrame?

I am guessing fromt he above error that calling another class file from an applet is prohibited. Is there any way I can display the PollFrame from the applet?

推荐答案

好像你调用 setDefaultCloseOperation()您的JFrame,这引发安全异常

It seems like you're calling setDefaultCloseOperation() on your JFrame, which raises the security exception

您可以明确地调用另一个类从applet但一些操作受到限制,例如。你不能打开本地文件,打开连接到其它机器...

You can definitively call another class from an applet but some operations are restricted, eg. you can't open local files, open connections to other machines...

这篇关于如何显示从applet一个JFrame?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆