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 *

Amrmsmb
  • 1
  • 27
  • 104
  • 226
  • @Hovercraft Full Of Eels the question you suggested does not answer my question – Amrmsmb May 06 '15 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. – kiheru May 06 '15 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**. – Hovercraft Full Of Eels May 06 '15 at 15:53

0 Answers0