打开一个新的JFrame [英] Open a new 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).
新的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);
- can't resist, simple disagree with answers
JFrame frame = new JFrame(
); andframe.setVisible(true);
-
不要这样做,仅创建两个JFrames ,重复使用2.
JFrame
通过JFrame
用于JButton
don't do that, create only two JFrames, reuse 2nd.
JFrame
by usinggetContentPane.removeAll()
, for another actions fromJButton
然后所有生命周期仅约
setVisible(true)
/setVisible(false)
then all lifecycle will be only about
setVisible(true)
/setVisible(false)
将
DefaultCloseOperations
更改为HIDE_ON_CLOSE
新的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
有什么问题,与JFrame
中的三个按钮相比,Toolbar
中只有一个按钮,简单不同意, - whats wrong with
JDialog
, only one button in theToolbar
in compare with three buttons inJFrame
, simple disagree, - 使用
SwingWorker
或Runnable#Thread
(必须包装到invokeLater
中)获取放置在JDialog中的JComponent的值,如果完成所有更改,请调用包装在invokeLater()
中的JDialog.setVisible(true)
- use
SwingWorker
orRunnable#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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
-
当用户点击第一个计算时,我想打开一个新的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).