Creating dynamic amount of components in FXML

后端 未结 1 1082
半阙折子戏
半阙折子戏 2020-12-22 04:57

I made a note card program that can help you study with JavaFX. It saves the class through XML and on boot up, it finds the XML files and adds them to an ArrayList called al

相关标签:
1条回答
  • 2020-12-22 05:42

    No you cannot do this in FXML. There is no way to write a LOOP in fxml. If you are just considered about a Button, then you may use SceneBuilder and drag-drop multiple buttons.

    Though, if you are considered about a more complex UI and want to repeat them, you can create a separate FXML and include it as many time as you need using <fx:include>.

    You can also load the same fxml multiple times using a loop and put all the concerned data inside the initialize(), but this might not be the best solution you are looking for.

    0 讨论(0)
提交回复
热议问题