我现在花了一些时间试图弄清楚我的逻辑在哪里有缺陷,并且在这里看到了类似的问题,但由于某种原因我不断得到nullPointerException:
public class MainWindowController
implements Initializable {
public static final String SCHEDULE_MANAGER = "ScheduleManagerController";
public static final URL SCHEDULE_MANAGER_FXML = ScheduleManagerController.class.getResource("ScheduleManager.fxml");
final SwitchableStackPane customStackPane = new SwitchableStackPane();
@FXML
Button btnScheduleManager; // Value injected by FXMLLoader
BorderPane switchablePane; //Value injected by FXMLLoader
@Override // This method is called by the FXMLLoader when initialization is complete
public void initialize(URL fxmlFileLocation, ResourceBundle resources) {
assert btnScheduleManager != null : "fx:id=\"ScheduleManager\" was not injected: check your FXML file 'HOECTool.fxml'.";
assert switchablePane != null : "fx:id=\"mainPane\" was not injected: check your FXML file 'HOECTool.fxml'.";
customStackPane.loadScreen(SCHEDULE_MANAGER, SCHEDULE_MANAGER_FXML);
switchablePane.setCenter(customStackPane);
}
抛出nullPointer异常: switchablePane.setCenter(customStackPane);
答案 0 :(得分:0)
排序,我是个白痴。这样做了:
@FXML
Button btnScheduleManager; // Value injected by FXMLLoader
@FXML
BorderPane switchablePane; //Value injected by FXMLLoader