0

In my code i generate some images and display them every image in a jframe, but when i close on the jframes i found all the other closes as well. I want when i close one of the jframes, the others remain.

how can i do that.

code:

private static void initJFrame(String caption) { // TODO Auto-generated method stub if (caption.isEmpty() || caption.equals("")) { caption = SysConsts.DEFAULT_JFRAME_CAPTION; } JFrame mediaFrame = new JFrame(caption); mediaFrame .setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mediaFrame.setSize(SysConsts.DEFAULT_JFRAME_WIDTH, SysConsts.DEFAULT_JFRAME_HEIGHT); facePanel = new FacePanel(); mediaFrame.setContentPane(facePanel); mediaFrame.setVisible(true); mediaFrame.validate(); } 

@Hovercraft Full Of Eels: your suggestion does not answer my question *

3
  • @Hovercraft Full Of Eels the question you suggested does not answer my question Commented May 6, 2015 at 14:54
  • JFrame.EXIT_ON_CLOSE the program exits, so obviously the other frames are closed as well. If you insist on using multiple frames you need to track them yourself, and only exit when the last frame is closed. Commented May 6, 2015 at 14:57
  • Yes it does answer your question: Don't use multiple JFrames. If you absolutely need multiple windows, make the secondary windows JDialogs since you can't close the GUI by closing a JDialog. Commented May 6, 2015 at 15:53

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.