Java 关闭/退出子帧而不关闭父帧
我在另一个帧中创建了第二个帧。 我注意到当我关闭第二帧时,第一帧也会关闭 我怎样才能避免呢? 我希望第一帧保持原样,不关闭 第二帧的代码是:Java 关闭/退出子帧而不关闭父帧,java,swing,jframe,exit,Java,Swing,Jframe,Exit,我在另一个帧中创建了第二个帧。 我注意到当我关闭第二帧时,第一帧也会关闭 我怎样才能避免呢? 我希望第一帧保持原样,不关闭 第二帧的代码是: JFrame.setDefaultLookAndFeelDecorated(true); frame = new JFrame(); frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE); //when it closes the first frame closes too 谢谢已解
JFrame.setDefaultLookAndFeelDecorated(true);
frame = new JFrame();
frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE); //when it closes the first frame closes too
谢谢已解决
frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
我读了下面的答案,找到了答案
- I已删除
frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
- 我添加了以下内容
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);