打开一个新的JFrame [英] Open a new JFrame

查看:123
本文介绍了打开一个新的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(); and frame.setVisible(true);
    • 当用户点击第一个计算时,我想打开一个新的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).

      • 不要这样做,仅创建两个JFrames ,重复使用2. JFrame通过JFrame用于JButton

        • don't do that, create only two JFrames, reuse 2nd. JFrame by using getContentPane.removeAll(), for another actions from JButton

          然后所有生命周期仅约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 the Toolbar in compare with three buttons in JFrame, simple disagree,
            • 输出窗口(类似于SPSS输出窗口,如果您熟悉的话 他们).

              Output window (Simlar to SPSS output windows if you are familiar with them).

              • 使用SwingWorkerRunnable#Thread(必须包装到invokeLater中)获取放置在JDialog中的JComponent的值,如果完成所有更改,请调用包装在invokeLater()中的JDialog.setVisible(true)
                • use SwingWorker or Runnable#Thread (required wrap into invokeLater) for get value for JComponents placed into JDialog, if all changes are done call JDialog.setVisible(true) wrapped into invokeLater()
                • 这篇关于打开一个新的JFrame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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