Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Close Operation Java

Tags:

java

swing

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?

like image 977
Bishan Avatar asked May 10 '12 06:05

Bishan


People also ask

What is default close operation in Java?

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.

How do I close a Java 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.

Why setVisible () method is used?

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.

Which one method is used to set the close operation?

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.


1 Answers

You need to write a window listener.

like image 159
michael667 Avatar answered Oct 01 '22 23:10

michael667