我通过窗体A 调用 窗体 B,点击窗体B右上角的x关闭窗体B,然后就退出整个程序了
请问怎么才能关闭B,但是保留A呢
A是用SwingUtilities.invokeLater执行的
A的调用代码:
public static void main(String[] args) throws InvocationTargetException, InterruptedException{ SwingUtilities.invokeLater(new Runnable(){ public void run() { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); try { //设置皮肤 UIManager.setLookAndFeel( new SubstanceOfficeBlue2007LookAndFeel()); } catch (UnsupportedLookAndFeelException e) { // TODO Auto-generated catch block e.printStackTrace(); } ChatView cv = new ChatView(); name = "大肚腩"; cv.setTitle(name); cv.setSize(500,400); // cv.setResizable(false); //不允许用户改变窗口大小 cv.setDefaultCloseOperation(EXIT_ON_CLOSE); // com.sun.awt.AWTUtilities.setWindowOpacity(cv, .7f); cv.setVisible(true); cv.setLocationRelativeTo(null); } }); }
不要使用 setDefaultCloseOperation(EXIT_ON_CLOSE),使用 DISPOSE_ON_CLOSE