java - Password popup not closing program if cancel is pressed -
i trying create password protected program. can't seem programme close if person hits cancel. have question. if programme jar file system.exit(0);
close it?
string password = joptionpane.showinputdialog(gamewindow,"please come in password.","security alert",joptionpane.warning_message); if (password.equalsignorecase("password")) { } else { system.exit(0); }
you getting null pointer exception.
do next if statement.
if (password != null && password.equalsignorecase("password")) { } else { system.exit(0); }
when cancel password set null (same if exit), need check that, because otherwise programme crashes.
java
No comments:
Post a Comment