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

前端 未结 2 1650
你的背包
你的背包 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:54

    Don't just include fxml, create a business logic layer for that:

    
    

    and update it in button click handlers:

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

提交回复
热议问题