我遇到的问题是,当我单击“登录”按钮时,它什么也没做。没有抛出异常,并且 try - catch 似乎没有捕获任何错误/异常。一直在浏览线程,但没有发现任何有效的东西。
我在整个代码中添加了 print 语句,似乎在第一个 try 块的开头就停止了,还在两个 catch 块中添加了 stackTrace 但什么也没有
void getLoginAction(ActionEvent event) throws IOException, Exception {
String username = tfUsername.getText();
String password = tfPassword.getText();
loggingUsers.setUserName(username);
loggingUsers.setPassword(password);
FileHandler userFh = new FileHandler("UserLog.txt", true);
SimpleFormatter sf = new SimpleFormatter();
userFh.setFormatter(sf);
uLog.addHandler(userFh);
uLog.setLevel(Level.INFO);
try {
ObservableList<User> loginInfo = DatabaseMan.getActiveUsers();
loginInfo.forEach((u) -> {
try {
assert loggingUsers.getUserName().equals(u.getUserName()) && loggingUsers.getPassword().equals(u.getPassword()) : "Incorrect login info!";
loggingUsers.setUserId(u.getUserId());
try {
Appointment upcomingAppt = DatabaseAppointments.getUpcomingAppt();
if (!(upcomingAppt.getAppointmentId() == 0)) {
Alert apptAlert = new Alert(Alert.AlertType.INFORMATION);
apptAlert.setTitle("Upcoming Appointment Reminder");
apptAlert.setHeaderText("You have an upcoming appointment!");
apptAlert.setContentText("You have an appointment scheduled"
+ "\non " + upcomingAppt.getStart().format(DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL))
+ "\nat " + upcomingAppt.getStart().format(DateTimeFormatter.ofLocalizedTime(FormatStyle.FULL))
+ " with client " + upcomingAppt.getCustomer().getCustomerName() + ".");
}
没有错误消息,按下按钮时没有任何反应
长风秋雁
相关分类