09.04.2018 Views

tornadofx-guide

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

4. Basic Controls<br />

radiobutton("Power User Mode") {<br />

action {<br />

println("Power User Mode: $isSelected")<br />

}<br />

}<br />

Figure 4.13<br />

Also like the ToggleButton , you can set a RadioButton to be included in a ToggleGroup so<br />

that only one item in that group can be selected at a time (Figure 4.14).<br />

import javafx.scene.control.ToggleGroup<br />

import <strong>tornadofx</strong>.*<br />

class MyView : View() {<br />

private val toggleGroup = ToggleGroup()<br />

}<br />

override val root = vbox {<br />

radiobutton("Employee", toggleGroup)<br />

radiobutton("Contractor", toggleGroup)<br />

radiobutton("Intern", toggleGroup)<br />

}<br />

Figure 4.14<br />

DatePicker<br />

The DatePicker allows you to choose a date from a popout calendar control. You can<br />

optionally provide a block to manipulate it (Figure 4.15).<br />

datepicker {<br />

}<br />

value = LocalDate.now()<br />

Figure 4.15<br />

41

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

Saved successfully!

Ooh no, something went wrong!