简体   繁体   English

我应该创建一个新窗口还是修改旧窗口?

[英]Should I create a new window or modify the old one?

I am programming a GUI application in Java. 我正在用Java编写GUI应用程序。 I do it for the first time. 我是第一次做。

I would like to have a form (with radio buttons and so on). 我想要一个表格(带有单选按钮等)。 After the form is filled in and the "Submit" button is pressed I would like to have a new window. 填写表格并按下“提交”按钮后,我想要一个新窗口。 I see two potential ways to do it: 我看到两种可能的方法:

  1. Close the "old" window and open a "new" one. 关闭“旧”窗口,然后打开“新”窗口。

  2. Remove "old" elements from the existing window and put there "new" elements. 从现有窗口中删除“旧”元素,然后放置“新”元素。

What is the standard way to go? 标准方式是什么? If it is the first way, what is the command to close the window? 如果是第一种方法,关闭窗口的命令是什么? If it is the second one, how can I remove elements from the existing window? 如果是第二个,如何从现有窗口中删除元素?

您应该做的是为要显示的所有窗口创建新的JPanel ,然后删除(或隐藏)要隐藏的面板并添加或显示要显示的面板。

我对Java不太了解,所以我无法回答您的特定问题,但是我想提醒您自Windows Vista以来的窗口打开/关闭效果:在某些较旧的设置向导中,每次您看起来都很奇怪单击下一步,窗口逐渐淡出并进入...

I think the most logical way is to have 2 objects( "Close the "old" window and open a "new" one" ) 我认为最合乎逻辑的方式是拥有2个对象( “关闭“旧”窗口并打开“新”窗口”

Anyway, I suggest you make an abstract class with the common elements, and then extend it with Window1 and Window2 . 无论如何,我建议您使用公共元素创建一个抽象类,然后使用Window1Window2对其进行扩展。

Java框架使用dispose()方法销毁。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从旧实例创建新实例? - How do I create a new instance from an old one? 我如何创建新的ArrayList <ArrayList<Integer> &gt;在不更改旧版本的情况下从旧版本中删除? - How can I create new ArrayList<ArrayList<Integer>> from an old one without changing the old one? 如何打开一个新标签页而不关闭Selenium中的旧标签页,保留先前的窗口 - How do I open a new tab and without closing the old one in Selenium, retain the previous window 我应该创建新类还是使用现有的类 - Should I create new class or use the existing one 我应该重用一个GSON实例还是按需创建新实例? - Should I reuse one instance of GSON or create new ones on demand? 如何创建一个不与旧窗口同步的jEdit“New View” - How to create a jEdit “New View” that not synchronize with the old window 如何使按钮打开一个新窗口并关闭旧窗口 - How to make a button open a new window and close the old one 如何使用旧数组的一部分在Java中创建一个新数组? - How do I use parts of an old array to create a new one in java? 什么时候应该创建新的线程组 - When should one create new Thread Groups 如何清除旧窗口的内容并向其中添加新信息? - How can I clear content for an old window and add new info to it?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM