class StockItem(var sku : String, var amount : Int = 0) class StockItemModel : ItemViewModel() { val skuProperty : StringProperty = bind { SimpleStringProperty(item?.sku) } val amountProperty : IntegerProperty = bind { SimpleIntegerProperty(item?.amount ?: 0) } } class StockItemView : View("Stock Item") { val model : StockItemModel by inject() override val root = vbox { label("SKU") textfield(model.skuProperty) label("Amount") textfield(model.amountProperty) hbox { button("Decr") { setOnAction { if( model.amountProperty.value > 0 ) { model.amountProperty.value-- } } } button("Incr") { setOnAction { model.amountProperty.value++ } } spacing = 4.0 } paddingAll = 40 spacing = 10.0 } init { model.skuProperty.value = "ITEM-0001" model.amountProperty.value = 1 } } class StockItemApp : App(StockItemView::class) fun main(args: Array) { launch(args) }