问题
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