0

I have made a program in which three jframe is exist. But the problem is that when I close one jframe all the remaining opening jframe is also closed. Please help me.

  • 1
    [First search on google](https://stackoverflow.com/questions/1944446/close-one-jframe-without-closing-another). Try to search before asking. – Deggo Aug 09 '17 at 06:25
  • See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/q/9554636/418556) – Andrew Thompson Aug 09 '17 at 07:14

3 Answers3

2

If you do not want your application to terminate when a JFrame is closed, use

frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
Adeel
  • 413
  • 1
  • 7
  • 22
0

It may be specific need for your project to create 3 JFrames but it is a good GUI making practice, to create only a single JFrame.
For additional windows, which you want to open from parent JFrame, you can easily use JDialogs which offers more functionalities over opening a new child JFrame. :-)

Aman
  • 735
  • 1
  • 6
  • 19
-1

You can Use jframe.dispose() function or if you use NetBeans then you find a option in project properties the defaultCloseOperation tab then select Dispose from drop Down Menu

Arm Avi
  • 21
  • 1
  • 1
  • 3