最近在写一个文本编辑器,里面用到了新建文档,我用的是重新创建一个文本编辑器类的实例 如:
public class editor extends JFrame implements ....{ public void ActionPerform(ActionEvent e){
if(e.getActioncommand()=="新建")
new editor();
}}但是当我关闭其中一个窗口时,整个程序都结束了,也就是全部是一个进程,请问高手怎么样把他们独立,想互不干扰呢。
public class editor extends JFrame implements ....{ public void ActionPerform(ActionEvent e){
if(e.getActioncommand()=="新建")
new editor();
}}但是当我关闭其中一个窗口时,整个程序都结束了,也就是全部是一个进程,请问高手怎么样把他们独立,想互不干扰呢。
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
//TODO 处理代码 }
}适用 dispose来关闭,应该在主窗口关闭时才使用 System.exit(0)