开发者

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

I am programming a GUI application in Java. 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 t开发者_运维百科o 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?


What you should do is create new JPanel for all the windows you want to show, then remove (or hide) the panel you want to hide and add or show the one you want to show.


I don't know too much about Java so I can't answer to your specific questions, but I want to remind you of the window opening/closing effect since Windows Vista: It looks kind of weird in some older setup wizards where everytime you click next the window fades out and in...


I think the most logical way is to have 2 objects("Close the "old" window and open a "new" one")

Anyway, I suggest you make an abstract class with the common elements, and then extend it with Window1 and Window2.


Java frames are destroyed with the dispose() method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜