1.实现界面登陆,退出功能的java代码怎么写
CS结构系统的退出如下:public void init() {
this.setTitle("用户登录界面");
this.add(createCenterPane());
this.(this.DO_NOTHING_ON_CLOSE);
this.setSize(new Dimension(450, 335));
this.setLocationRelativeTo(null);
// this.setVisible(true);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
int choose = JOptionPane.showConfirmDialog(null, "是否要退出登录界面?",
"系统提示:", JOptionPane.YES_NO_OPTION);
if (choose == JOptionPane.YES_OPTION) {
System.exit(1);
}
}
});
}其中this为JFrame对象。BS结构的退出直接用windows.close()方法就行了!
2.退出网页代码
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta ; charset=gb2312">
<script LANGUAGE="JavaScript">
<!--
var ifOpen=true;
function openDiaocha()
{
if(!ifOpen)return;
window.open ("/diaocha/a.asp", "_form", "height=310, width=365, toolbar =no, menubar=no, scrollbars=no, resizable=no, location=no, status=no");
}
//-->
</script>
<title>;无标题文档</title>
</head>
<body onbeforeunload='openDiaocha()'>
<div align="center"></div>
</body>
</html>
body里面的也要有,要不然不好用
3.退出网页代码
其实很简单,用脚本语言即可实现:(以下为退出网页是时的代码)<body onunload="leave()">。