0
當我單擊超鏈接時,我想更改位於主應用程序邊框窗格中心的場景。所以,我編寫我的程序如下JavaFX:如何更改包含在BorderPane中心的場景
private BorderPane borderPane;
private AnchorPane connectionPage;
@FXML
private Hyperlink hyperLink1;
@FXML
private void handleHyperLink1OnAction() {
try {
connectionPage=FXMLLoader.load(getClass().getResource("ConnectionViewer.fxml"));
} catch (Exception e) {
System.out.println(e.getStackTrace().toString());
System.out.println(e.getMessage());
}
borderPane.setCenter(connectionPage);
}
這是我的主要應用
public void start(Stage primaryStage) throws Exception {
Parent welcomePage = FXMLLoader.load(getClass().getResource("ManagerWorldViewer.fxml"));
Scene scene = new Scene(welcomePage);
primaryStage.setScene(scene);
primaryStage.show();
}
一旦我運行這個程序,沒有什麼變化,沒有出現錯誤。請幫我
是否有borderpane @FXML註釋? –
噢,我..我忘記了,非常感謝 – James