Open a new JFrame(打开一个新的 JFrame)
问题描述
我有一个主 JFrame,其中包含用于不同功能的各种面板,人们可以在其中计算事物.我想在用户点击第一个计算按钮时打开一个新的 JFrame 并用作输出窗口(如果您熟悉它们,则类似于 SPSS 输出窗口).
I have a main JFrame that has all kinds of panels in it for different functions and people can calculate things in them. I want to open a new JFrame when the user hits the first calculate button and serve as a Output window (Simlar to SPSS output windows if you are familiar with them).
New JFrame 将完全独立,并拥有自己的菜单栏...此处不适合使用简单的 JDialog.
The New JFrame will be completely separate and will have its own menu bar ... A simple JDialog is not the way to go here.
推荐答案
- 无法抗拒,简单不同意答案
JFrame frame = new JFrame();和frame.setVisible(true); 不要那样做,只创建两个 JFrame, 重用第 2 个.
JFrame使用getContentPane.removeAll(),用于来自JButtondon't do that, create only two JFrames, reuse 2nd.
JFrameby usinggetContentPane.removeAll(), for another actions fromJButton那么所有的生命周期将只涉及
setVisible(true)/setVisible(false)then all lifecycle will be only about
setVisible(true)/setVisible(false)将
DefaultCloseOperations更改为HIDE_ON_CLOSENew JFrame 将完全独立,并拥有自己的菜单酒吧.一个简单的 JDialog 不是这里的方法.
The New JFrame will be completely separate and will have its own menu bar. A simple JDialog is not the way to go here.
JDialog有什么问题,Toolbar中只有一个按钮,而JFrame中只有三个按钮,根本不同意,- whats wrong with
JDialog, only one button in theToolbarin compare with three buttons inJFrame, simple disagree, - 使用
SwingWorker或Runnable#Thread(需要包装到invokeLater)获取放置在 JDialog 中的 JComponents 的值,如果所有更改都已完成调用JDialog.setVisible(true)封装到invokeLater() - use
SwingWorkerorRunnable#Thread(required wrap intoinvokeLater) for get value for JComponents placed into JDialog, if all changes are done callJDialog.setVisible(true)wrapped intoinvokeLater()
输出窗口(类似于 SPSS 输出窗口,如果您熟悉他们).
Output window (Simlar to SPSS output windows if you are familiar with them).
这篇关于打开一个新的 JFrame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
我想在用户点击第一个计算时打开一个新的 JFrame按钮并用作输出窗口(类似于 SPSS 输出窗口,如果你熟悉它们).
I want to open a new JFrame when the user hits the first calculate button and serve as a Output window (Simlar to SPSS output windows if you are familiar with them).
本文标题为:打开一个新的 JFrame
基础教程推荐
- doFilter()是在servlet的工作完成之前还是之后执行的? 2022-01-01
- 在springboot中如何给mybatis加拦截器 2023-04-29
- Maven:无效的目标版本:10 2022-01-01
- 如何在相机中应用自定义滤镜 [Surfaceview 预览]. 2022-01-01
- JPA惰性列表上的流 2022-01-01
- 在java中使用xpath和selenium解析HTML表格数据 2022-01-01
- 将 double 转换为 Int,向下舍入 2022-01-01
- 将 Windows 证书导入 Java 2022-01-01
- Java ECDSAwithSHA256 签名长度不一致 2022-01-01
- 控制台应用程序中的 Java 键盘输入解析 2022-01-01
