How to change sub fxml gui parts at runtime with Button Click

前端 未结 2 1675
你的背包
你的背包 2021-02-01 06:23

I\'m tryin to build a skeleton for a big complex gui, so the idea is to make everything with mvc like style in javafx 2.1, so every component has a fxml file and if needed css,c

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-01 06:57

    it works,thx for help, but i was forced to remove TaskBar.fxml and TaskBarController.java , wrote a MainViewController with @FXML handles and @FXML for the Buttons and the Pane with the fx:id="content" , and put my customs Buttons in MainView.fxml

    @FXML
    private void handleTaskBarButton2Action(ActionEvent event) throws IOException {
        System.out.println("click! taskBarButton2");
        content.getChildren().clear();
        content.getChildren().add((Node) FXMLLoader.load(getClass().getResource("Content2.fxml")));
    }
    

提交回复
热议问题