关闭/退出子框架而不关闭父框架

pro*_*mer 2 java swing exit jframe

我在另一帧中创建了第二帧.我注意到当我关闭第二帧时,第一帧也会关闭.

我怎么能避免这种情况?我希望第一帧保持原样而不关闭.

我的第二帧代码是:

 JFrame.setDefaultLookAndFeelDecorated(true);       
 frame = new JFrame();
 frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE); //when it closes the first frame closes too
Run Code Online (Sandbox Code Playgroud)

谢谢

pro*_*mer 5

解决了

我看了以下答案关闭一个JFrame而不关闭另一个?我找到了答案

  • 应用程序应该只有一个JFrame.对于子窗口,您应该使用JDialog.请参阅:http://stackoverflow.com/questions/9554636/the-use-of-multiple-jframes-good-bad-practice (4认同)