-2

I want my JFrame program to close as soon as a boolean isDead is true.

How do I do this?

if (isDead) {
    // Close the program
}

JFrame obj = new JFrame();
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • 1
    Does this answer your question? [How to programmatically close a JFrame](https://stackoverflow.com/questions/1234912/how-to-programmatically-close-a-jframe) – ajc2000 Aug 04 '20 at 18:22

2 Answers2

1

just use frame.setActive(false) (this will just hide the frame and if you want to close the whole program)

0
setVisible(false); 
dispose();

Hasindu Dahanayake
  • 1,344
  • 2
  • 14
  • 37