JavaFX:如何更改包含在边框窗格中心的场景
我想在单击超链接时更改位于主应用程序中边界窗格中心的场景。所以我把我的程序编码如下JavaFX:如何更改包含在边框窗格中心的场景,java,javafx-8,Java,Javafx 8,我想在单击超链接时更改位于主应用程序中边界窗格中心的场景。所以我把我的程序编码如下 private BorderPane borderPane; private AnchorPane connectionPage; @FXML private Hyperlink hyperLink1; @FXML private void handleHyperLink1OnAction () { try { connectio
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();
}
一旦我运行这个程序,就不会有任何改变,也不会发生错误。请帮助我我错过了@FXML注释。所以我把源代码改为
@FXML
private BorderPane borderPane;
@FXML
private AnchorPane anchorPane;
private void changeScreenOfCenter(String path, VBox menuVBox) {
VBox getVbox = menuVBox;
try {
anchorPane = FXMLLoader.load(getClass().getResource(path));
} catch (Exception e) {
System.out.println(e.getStackTrace().toString());
System.out.println(e.getMessage());
}
}
它是有效的。borderpane@FXML有注释吗?哦,天哪……我忘了,非常感谢