Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JavaFX:如何更改包含在边框窗格中心的场景_Java_Javafx 8 - Fatal编程技术网

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有注释吗?哦,天哪……我忘了,非常感谢