[英]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:
我看到两种可能的方法:
Close the "old" window and open a "new" one. 关闭“旧”窗口,然后打开“新”窗口。
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
. 无论如何,我建议您使用公共元素创建一个抽象类,然后使用
Window1
和Window2
对其进行扩展。
Java框架使用dispose()方法销毁。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.