
正文
java退出的代码 java退出系统的代码
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
JAVA 中 按回车键退出的 程序代码怎么写?
import java.io.IOException;
public class TestEnter {
public static void main(String[] args) throws IOException{
while(true){
if(System.in.read() == '\n')
System.exit(0);
}
}
}
相关问答
Q1: 实现 界面登陆 退出 功能的java代码杂写
CS结构系统的退出如下:public void init() {
this.setTitle("用户登录界面");
this.add(createCenterPane());
this.setDefaultCloseOperation(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()方法就行了!
Q2: JAVA退出函数的代码,替代return;
boolean b =true;
while(b){
b=true是这里面一直执行,你不想执行了,就把在这里把b的值改为false;
}
Q3: 实现界面登陆,退出功能的java代码怎么写?
CS结构系统的退出如下:public void init() {\x0d\x0a this.setTitle("用户登录界面");\x0d\x0a this.add(createCenterPane());\x0d\x0a this.setDefaultCloseOperation(this.DO_NOTHING_ON_CLOSE);\x0d\x0a this.setSize(new Dimension(450, 335));\x0d\x0a this.setLocationRelativeTo(null);\x0d\x0a // this.setVisible(true);\x0d\x0a this.addWindowListener(new WindowAdapter() {\x0d\x0a public void windowClosing(WindowEvent e) {\x0d\x0a int choose = JOptionPane.showConfirmDialog(null, "是否要退出登录界面?",\x0d\x0a "系统提示:", JOptionPane.YES_NO_OPTION);\x0d\x0a if (choose == JOptionPane.YES_OPTION) {\x0d\x0a System.exit(1);\x0d\x0a }\x0d\x0a }\x0d\x0a });\x0d\x0a }其中this为JFrame对象。BS结构的退出直接用windows.close()方法就行了!
java退出的代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java退出系统的代码、java退出的代码的信息别忘了在本站进行查找喔。








