Calling view method in controller

前端 未结 1 1114
甜味超标
甜味超标 2021-01-14 20:17

I want invoke view method in controller but I don\'t know how :) I sought like example, but I don\'t found it. Can I do that in this code ? whether I must build it anew ? I

相关标签:
1条回答
  • 2021-01-14 20:54

    put this code in FXMLExampleMVC.java

    private static FXMLExampleMVC instance;
    public FXMLExampleMVC() {
               instance = this;
    }
    // static method to get instance of view
    public static FXMLExampleMVC getInstance() {
            return instance;
    }
    

    and now you can call your view methods in controller like this

      @FXML protected void handleSubmitButtonRegister() throws IOException{
            // 
           //Here I want to invoke gotoRegister
            FXMLExampleMVC.getInstance().gotoRegister();
        }
    
    0 讨论(0)
提交回复
热议问题