I want to close a Frame automatically not by clicking the close button. I want it to be closed programmaticaly.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
I want to close a Frame automatically not by clicking the close button. I want it to be closed programmaticaly.
Either
orframe.dispose();
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:
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.