I want to close a Frame automatically not by clicking the close button. I want it to be closed programmaticaly.
Printable View
I want to close a Frame automatically not by clicking the close button. I want it to be closed programmaticaly.
Either
orCode :frame.dispose();
Code :frame.setVisible(false);
The first will actually dispose of the JFrame and all of its components, the second just make it invisible if you ever want to make it visible again during the duration of the program.
but each of them that I use I get the following error;
"Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException"
Post an SSCCE* or it didn't happen. (link below)
* SSCCE : Java Glossary
db
Make sure that the frame you are trying to dispose of exists and is running:
Code :if (frame != null) { frame.dispose(); }
thank you for your point. when I check if the frame is null it returns null but I can see that the frame is open and it is not closed. how is it possible?
So where's that SSCCE?
db
I am still patient!:)
Good for you.
db
good for you that don't have the answer to my question.