tags:

views:

54

answers:

4

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 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?

+1  A: 

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...

eWolf
You probably should not code an application based on how it looks under a specific window manager but rather based on the application and standard UI conventions.
msw
Of course you are right. But this effect for sure is regarded in the windows UI guidelines. So if you want it too seem like it stays the same, or at least part of it, like in a wizard, keep the window. If you want to show something entirely new, maybe even at a different size, make a new one.
eWolf
+1  A: 

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.

True Soft
+4  A: 

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.

Thirler
A voice of reason.
Anders
Thanks for the answer. By the way, should I use `dispose()` to hide the "old" `JPanel`?
Roman
Just hide it using `setVisible(false)`.
Bombe
A: 

Java frames are destroyed with the dispose() method.

msw