Java: how do I close another JFrame when I open it?

My program starts with a picture with a text field in JFrame I want to close the picture JFrame and open another JFrame and the main program when the user type starts I tried

processEvent(new WindowEvent(this,WindowEvent.WINDOW_CLOSING));

On the image frame, but it closes all windows

Solution

Method JFrame Setvisible can be used to hide or display JFrame according to parameters, while JFrame Dispose will actually "destroy" the framework by closing it and releasing the resources it uses If you plan to reopen it, you can call setvisible (false) on the photo frame, or if you don't open it again, you can call dispose () on the photo frame, so that your program can free some memory You will then call setvisible (true) on the main framework to make it visible

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>