Java FX : How to call method from controller to another controller [closed]

天大地大妈咪最大 提交于 2020-07-31 06:06:31

问题


I woudlike to call method from another controller to enable/disable some Toggle Button.

Dashboard_controller :

// ENABLE BUTTON //

    public void setEnableBtn1() {
        btn1.setDisable(false);
    }
    public void setDisableBtn1() {
        btn1.setDisable(true);
    }

My another controller :

private dashboard_controller dashController; 

 public void initialize() throws IOException {
        String urlmain = "/view/main/main.fxml";
        FXMLLoader loader = new FXMLLoader(getClass().getResource(urlmain));
        dashController = new dashboard_controller();
        dashController = loader.getController();
        active();


private void active()
{
  dashController.setEnableBtn1();

}

But nothing change when I run my program. What I did wrong ?

来源:https://stackoverflow.com/questions/63153779/java-fx-how-to-call-method-from-controller-to-another-controller

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!