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

查看:39
本文介绍了打开一个新的 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按钮并用作输出窗口(类似于 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, 重用第 2 个.JFrame 使用 getContentPane.removeAll(),用于来自 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

        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.

        • JDialog 有什么问题,Toolbar 中只有一个按钮,而 JFrame 中只有三个按钮,根本不同意,
          • 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 中的 JComponents 的值,如果所有更改都已完成调用 JDialog.setVisible(true) 封装到 invokeLater()
              • 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天全站免登陆