계정을 만들고 해당 계정에 로그인 할 수있는 간단한 JAVA 게임 실행기가 있습니다. 로그인하면 로그 오프 할 수있는 옵션이있어서 실행기의 메인 메뉴로 되돌아갑니다. 모두 작동하지만 다시 로그인하면 로그 오프 버튼이 더 이상 존재하지 않습니다.JButton 문제가 보이지 않습니까?
if (event.getSource().equals(logout)) {
isLogin = false;
UsRName = "";
PaSSWord = "";
logoff.setVisible(false);
ps.setVisible(false);
usrnm.setVisible(true);
pswrd.setVisible(true);
login.setText("Login");
register.setText("Need an Account?");
scroll.setVisible(true);
usr.setText("Username:");
ps.setText("Password:");
ps.setVisible(true);
usrnm.setText("");
pswrd.setText("");
System.out.println("done");
}
로그 오프를 로그 오프 JButton의이다 : 이 내 로그 오프 코드입니다. 다른 모든 것은 JFrame을 내가 원하는 방식으로 가져 오는 것입니다.
isLogin = true;
logoff.add(logout);
logout.setVisible(true);
frame.add(logoff);
lastLogin.replace("*", "");
//set the logged in look!
usrnm.setVisible(false);
pswrd.setVisible(false);
login.setText("Start Game");
register.setText("Account Settings");
scroll.setVisible(false);
usr.setText("");
ps.setVisible(true);
if (lastLogin == "") {
ps.setText("Welcome " + UsRName + "! You can Edit your Settings here.");
} else {
ps.setText("Welcome back " + UsRName + "! You last loged in " + lastLogin);
}
이것은 로그인 한 후 로그 오프 버튼의 가시성을 다시 설정하는 코드입니다. 그러나 로그인 이벤트가 호출되면 버튼이 여전히 표시되지 않습니다. 제안 사항이 있으십니까?
더 나은 도움을 받으려면 [MCVE] (http://stackoverflow.com/help/mcve)를 게시하십시오. –