By using frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
can hide window. but how could i display another window after that ?
When i click on close button
in my java swing application,i need to hide that window and display another window in my application. how could i do this?
Constants to set the default close operationHides the frame when the user closes the window. This is the default action. WindowConstants.DISPOSE_ON_CLOSE. Hides and disposes of the frame when the user closes the window.
We can close the AWT Window or Frame by calling dispose() or System. exit() inside windowClosing() method. The windowClosing() method is found in WindowListener interface and WindowAdapter class.
The setVisible(true) method makes the frame appear on the screen. If you forget to do this, the frame object will exist as an object in memory, but no picture will appear on the screen.
The setDefaultCloseOperation() method is used to specify one of several options for the close button. Use one of the following constants to specify your choice: JFrame. EXIT_ON_CLOSE — Exit the application.
You need to write a window listener.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With