如何在小程序中显示新框架?
我有一个小程序。在此我有一个 JLabel 组件。当用户单击此标签时,将显示一个新的 JFrame 组件。我想将此框架的 setDefaultCloseOperation() 值设置为 JFrame.EXIT_ON_CLOSE。但是,如果我这样做,我会收到 SecurityException。我阅读了 JFrame.EXIT_ON_CLOSE 的文档,其内容如下:
退出应用程序默认窗口关闭操作。如果窗口将此设置为关闭操作并在小程序中关闭,则可能会抛出SecurityException。建议您仅在应用程序中使用此操作。
我从上面了解到的是,如果在没有指定默认关闭操作的情况下关闭框架,则该框架仅被隐藏。我想在用户尝试关闭框架时关闭框架,而不是隐藏框架。这可能吗?
I have an applet. In this I have a JLabel component. When the user clicks this label, a new JFrame component gets displayed. I want to set the value of setDefaultCloseOperation() for this frame as JFrame.EXIT_ON_CLOSE. However, I get a SecurityException if I do that. I read the documentation of JFrame.EXIT_ON_CLOSE and its written that :
The exit application default window close operation. If a window has this set as the close operation and is closed in an applet, a SecurityException may be thrown. It is recommended you only use this in an application.
What I understood from the above is that if a frame is closed without specifying default close operation, the frame is only hidden. I want to close the frame when the user tries to close it, and not hide the frame. Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不允许在小程序中退出应用程序,而是可以使用 DISPOSE_ON_CLOSE 来完全删除 JFrame。
You are not allowed to exit the application in an applet, Rather you can use DISPOSE_ON_CLOSE which removes the JFrame completely.