Views
8 months ago

tornadofx-guide

7. Layouts and Menus

7. Layouts and Menus Awesome right? You can specify one or more controls for each of the fields, and the Form will render the groupings and labels for you. You can choose to lay out the label above the inputs as well: fieldset("FieldSet", labelPosition = VERTICAL) Each field represents a container with the label and another container for the input fields you add inside it. The input container is by default an HBox , meaning that multiple inputs within a single field will be laid out next to each other. You can specify the orientation parameter to a field to make it lay out multiple inputs below each other. Another use case for Vertical orientation is to allow an input to grow as the form expands vertically. This is handy for displaying TextAreas in Forms: form { fieldset("Feedback Form", labelPosition = VERTICAL) { field("Comment", VERTICAL) { textarea { prefRowCount = 5 vgrow = Priority.ALWAYS } } buttonbar { button("Send") } } } Figure 7.8 96

7. Layouts and Menus The example above also uses the buttonbar builder to create a special field with no label while retaining the label indent so the buttons line up under the inputs. You bind each input to a model, and you can leave the rendering of the control layouts to the Form . For this reason you will likely want to use this over the GridPane if possible, which we will cover next. Nesting layouts inside a Form You can wrap both fieldsets and fields with any layout container of your choosing to create complex form layouts. 97

GUIDE
GUIDE
Guide
GUIDE
Guide
GUIDE
GUIDE
GUIDE
Guide
GUIDE
Guide
GUIDE
Guide
GUIDE
GUIDE
Guide