I want to display two (or more) JFrames at the same time.
When I close one of them (use the default close button), the other frames should still be visible.
How can I do that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you do not want your application to terminate when a
JFrameis closed, useinstead of
From the documentation:
DO_NOTHING_ON_CLOSE(defined in WindowConstants): Don’t do anything; require the program to handle the operation in the windowClosing method of a registered WindowListener object.HIDE_ON_CLOSE(defined in WindowConstants): Automatically hide the frame after invoking any registered WindowListener objects.DISPOSE_ON_CLOSE(defined in WindowConstants): Automatically hide and dispose the frame after invoking any registered WindowListener objects.EXIT_ON_CLOSE(defined in JFrame): Exit the application using the System exit method. Use this only in applications.This was my answer before the question was clarified, might still be useful:
You can use
setVisible(false)on yourJFrameif you want to display the same frame again.Otherwise call
dispose()to remove all of the native screen resources.