我遇到的問題是,當我單擊“登錄”按鈕時,它什么也沒做。沒有拋出異常,并且 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() + "."); }沒有錯誤消息,按下按鈕時沒有任何反應
1 回答

長風秋雁
TA貢獻1757條經驗 獲得超7個贊
我們放棄了標記到按鈕點擊上的 ActionEvent
這是我們命名 Action Event 的方式和代碼示例?屏幕截圖來自 Scene Builder
? ?@FXML
private void onBack() throws IOException{
? ? stage = (Stage)childTVPane.getScene().getWindow();// pane you are ON
? ? paneStart = FXMLLoader.load(getClass().getResource("start.fxml"));// pane you are GOING TO
? ? Scene scene = new Scene(paneStart);// pane you are GOING TO
? ? scene.getStylesheets().add(getClass().getResource("diary.css").toExternalForm());
? ? stage.setScene(scene);
? ? stage.setTitle("Diary");?
? ? stage.show();
? ? stage.sizeToScene();
? ? stage.centerOnScreen();?
}
添加回答
舉報
0/150
提交
取消