我遇到的问题是,当我单击“登录”按钮时,它什么也没做。没有抛出异常,并且 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
提交
取消