这是我的登录代码。我的代码运行正常,直到它到达需要将屏幕切换到我的主页的部分。显示"您已登录!"消息它结束了程序。有任何想法吗?我正在使用NetBeans 7.3.1
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
boolean valid = false;
String user = txtUser.getText();
String pass = txtPass.getText();
try {
Scanner sc = new Scanner(new File("file.txt"));
while(sc.hasNextLine()){
String[] line = sc.nextLine().split("#");
if(line[0].equals(user) && line[1].equals(pass)){
valid = true;
}
}
} catch (FileNotFoundException ex) {}
if(valid == true){
JOptionPane.showMessageDialog(null, "You are now logged in!");
System.out.println("You are a user!");
//Doesn't run
HomePage adm = new HomePage();
adm.setVisible(true);
this.dispose();
}else{
JOptionPane.showMessageDialog(null, "Your username or password is incorrect!");
}
答案 0 :(得分:0)
检查您在 this.dispose()中正确处理的内容。您可能正在处理JFrame或包含其余UI组件的其他组件