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.

12. TornadoFX IDEA Plugin<br />

Do this for each property and your Client class should now look like this.<br />

class Client(id: Int, name: String) {<br />

var id by property(id)<br />

fun idProperty() = getProperty(Client::id)<br />

}<br />

var name by property(name)<br />

fun nameProperty() = getProperty(Client::name)<br />

Your Client now uses JavaFX properties instead of plain properties. Notice the primary<br />

constructor will pass the intial values to the property() delegates, but you do not have to<br />

provide initial values if they are not desired.<br />

This is a time-saving feature when creating domain types for data controls. Next we will<br />

cover how to generate TableView columns.<br />

Generating Columns for a TableView<br />

Another handy feature you can do with the plugin also is generating columns for a<br />

TableView . If you have a TableView , you can put the cursor on its declaration,<br />

press ALT + ENTER, and get a prompt to generate the columns (Figure 13.13).<br />

Figure 13.13<br />

186

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

Saved successfully!

Ooh no, something went wrong!