I am hoping that there is a way to open a different frame when Xing(pressing the X) out of another. I am aware of setDefaultCloseOperation() but could this open up a different frame? I know if I have a if(frame1.isVisible()) or a if(!frame1.isVisible()) I could do something like what I want, but the thing is sometimes it is supposed to not be visible. I want it so that the user will be able to press the X button at the top left, and have the frame that is supposed to come up, pop up.
Here is the scenario, I am making a game with a backpack, when you press the backpack button, the frame1 goes away, and backPackFrame pops up. There is a button for the user to press to make frame1 pop up and backPackFrame to go away, but some people will press the X thinking it will close the backPackFrame and make frame1 pop up. It doesn't, it will shut down the whole program.
Since there is more than frame1 and backPackFrame so I cant use if(frame1.isVisible()) or a if(!frame1.isVisible()) I need to know if I can be able to use something along the lines of setDefaultCloseOperation() to open up a different frame
Thanks in advance!