文件关闭的问题……
import javax.swing.*;import java.awt.event.*;
public class close
{
public static void main(String [] args)
{
new closed();
}
}
class closed extends JFrame
{
Object obj[] = {"OK","Cancel"};
public closed()
{
setSize(300,200);
setVisible(true);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent w)
{
int i = JOptionPane.showOptionDialog(null,"Exit OK?","Exit",JOptionPane.OK_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE,null,obj,obj[0]);
if(i == 0)
System.exit(0);
}
});
}
}
功能很简单,就是点大差而弹出对话框来询问是否关闭程序,但要写什么代码才能让点取消返回程序界面,现在点了就什么反应都没了……