跳到两页之间

时间:2014-10-29 02:52:51

标签: java javafx javafx-8

我写了两页,一页叫做段,另一页是crftest。首先我留在段页面,当我按下按钮时,我想跳到crftest页面。

错误信息在这里

at view.SegmentController.handlecrftest(SegmentController.java:33
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)

这是我的showcrftest函数,它跳转了crftestpage

public void showcrftest(){
            // Load crftest overview.
            try{
                FXMLLoader loader = new FXMLLoader();
                loader.setLocation(Main.class.getResource("../view/CRFtest.fxml"));

                crftestLayout = (AnchorPane) loader.load();

                // Show the scene containing the layout.
                Scene scene = new Scene(crftestLayout);
                primaryStage.setScene(scene);
                primaryStage.show();

                // Give the controller access to the main app.
                SegmentController controller = loader.getController();
                controller.setMain(this);

                }catch (IOException e) {   

                    e.printStackTrace();
                }

    }

这是我的控制器触发功能我按下名为handlecrftest()的按钮

public class SegmentController {
     // Reference to the main application
    private Main main;

    /**
     * Is called by the main application to give a reference back to itself.
     * 
     * @param mainApp
     */
    public void setMain(Main main) {
        this.main = main;
    }



    @FXML
    private void handlecrftest(){
        try{
            main.showcrftest();

        }catch(Exception e){

            e.printStackTrace();
        }


    } 

}

0 个答案:

没有答案