So I have two classes, Main
and MakeUserWindow
, inside of my Main
class I call MakeUserWindow
several times with different parameters by using a loop. The only problem is, this creates several windows that overlap each-other (Which isn't that much of a deal, it's just that I can get 20 windows on top of each-other). What I thought of doing was simply using window.dispose();
right before recalling the instance, however, when I do that it closes all instances of the window. Not allowing me to recreate the instance using the same variable. Is there a way of closing only the single instance like window.close();
that I am unaware about, or am is there just a better way of doing this? I have searched for awhile before coming here, no results have helped.
For some reference, here is a simplified version of what I am doing
(MakeUserWindow is a class that extends JFrame)
MakeUserWindow newWindow;
for(stuff){
newWindow.dispose();
newWindow = new MakeUserWindow("parameters here");
}
EDIT---
The reason I initialize MakeUserWindow
outside of the loop is because I need to use newWindow
's properties.
Thanks for reading, -Zach.