要是实现JFrame 关闭后程就退出或者停止可以调用setDefaultCloseOperation() 方法.
入下图程序
package ltb6w; import javax.swing.*; import java.awt.*; public class ChineseTextEdit { private JFrame jf; public ChineseTextEdit() { jf=new JFrame("文本编辑器"); jf.setSize(400, 200); jf.setLocationRelativeTo(null); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE ); jf.setVisible(true); } public static void main(String[] args) { new ChineseTextEdit(); } }