-2
ここにtableviewコントローラがあります。 ボタンを押すと、選択した行に関連付けられたデータをInstructorProfileContollerに送信しようとしています。コードの作品や版画は、あなたはメソッド呼び出しstage.showAndWait()
は段階を示しており、それが閉じられるまで待機選択した行の主キーを別のコントローラに送信し、その主キーを使用してデータをロードしようとしました。
Instructor instructor = (Instructor) InsTable.getSelectionModel().getSelectedItem();
if(instructor != null){
System.out.println("You select an instructor");
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("InstructorProfile.fxml"));
Parent root = fxmlLoader.load();
Stage stage = new Stage();
stage.setTitle("update instructor");
stage.setScene(new Scene(root));
stage.initModality(Modality.APPLICATION_MODAL);
stage.showAndWait();
InstructorProfileController instructorProfileController = fxmlLoader.getController();
instructorProfileController.countrychoicebox.setValue(instructor.getCountryID());
instructorProfileController.insstatuschoicebox.setValue(instructor.getIns_statusCode());
instructorProfileController.firstnametextfield.setText(instructor.getIns_firstName());
instructorProfileController.lastnametextfield.setText(instructor.getIns_lastName());
instructorProfileController.addresstextfield.setText(instructor.getIns_address());
instructorProfileController.citytextfield.setText(instructor.getIns_city());
// instructorProfileController.dateofBirthpicker.setValue(instructor.getIns_dateOfBirth());
instructorProfileController.gendertextfield.setText(instructor.getIns_sex());
instructorProfileController.zipcodetextfield.setText(String.valueOf(instructor.getIns_zipcode()));
}
initialize();
}
ありがとうございます!私は自分のコードが間違っていると思った –