Search code examples
javauser-interfacejavafxkotlintornadofx

What is the structure of a window in tornadofx?


So in javafx, windows of UI's are made like this: nodes inside scenes inside a stage. Sometimes nodes get nested inside other nodes. the structure of a javafx ui I know that in tornadofx, there are still nodes. They still nest inside each other. HBox, datagrid, etc. But in tornadofx, we use fragments and views. They are "UI elements", according to the manual. What are these? Are they nodes? Stages? Thanks!


Solution

  • A View or Fragment, or any UIComponent sub type, is a container for a root Node, which can be attached to anything a Node normally can be attached to. Think of View/Fragment as a Controller for the UI logic of a certain root node and it's children. With the builder syntax, you can "add" a View or Fragment to a Node. What happens under the covers is quite simply that the root node of the View is attached to the children list of the Node you add it to.