09.04.2018 Views

tornadofx-guide

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

7. Layouts and Menus<br />

item("SomeText", graphic = SomeNode, tag = SomeObject) {<br />

// Marks this item as active.<br />

activeItem = this<br />

}<br />

// Do some action when selected<br />

whenSelected { /* Action */ }<br />

Attribute<br />

Builder-<br />

Attribute<br />

Type Default Description<br />

text yes String? null<br />

tag yes Any? null<br />

graphic yes Node? null<br />

The text which should be set for the<br />

given item .<br />

The Tag can be any object or null<br />

and can be useful to identify the<br />

ListItem<br />

The graphic can be any Node and<br />

will be displayed beside the given<br />

text .<br />

Function<br />

Description<br />

whenSelected<br />

A convince function, which will be called anytime the given<br />

ListMenuItem is selected.<br />

Filling the parent container<br />

The useMaxWidth property can be used to fill the parent container horizontally. The<br />

useMaxHeight property will fill the parent container vertically. These properties actually<br />

applies to all Nodes, but is especially useful for the ListMenu .<br />

SqueezeBox<br />

JavaFX has an Accordion control that lets you group a set of TilePanes together to form an<br />

accordion of controls. The JavaFX Accordion only lets you open a single accordion fold at a<br />

time, and it has some other shortcomings. To solve this, TornadoFX comes with the<br />

SqueezeBox component that behaves and looks very similar to the Accordion, while<br />

providing some enhancements.<br />

113

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!