
1import javafx.application.Application 2import javafx.geometry.Pos 3import tornadofx.* 4 5fun main() = Application.launch(TestApp::class.java) 6class TestApp : App(TestView::class) 7class TestView : View("Learn") { 8 val maxDepth = intProperty(1) 9 val sliderr = intProperty(1) 10 val oldValuee = intProperty(0) 11 12 override val root = vbox(10) { 13 prefHeight = 200.0 14 prefWidth = 250.0 15 alignment = Pos.CENTER 16 label(maxDepth.stringBinding{"spinner, oldValue: ${oldValuee.value}, newValue: ${maxDepth.value}"}) 17 spinner(1, 10, 4, 1, true, maxDepth) { 18 minWidth = 200.0 19 valueProperty().addListener { _, oldValue, newValue -> 20 oldValuee.value=oldValue.toInt() 21 22 } 23 } 24 25 label(sliderr.stringBinding { "slider value: $it" }) 26 slider(1,10,4){ 27 maxWidth = 150.0 28 isShowTickLabels = true 29 isShowTickMarks = true 30 valueProperty().bindBidirectional(sliderr) 31 valueProperty().addListener { _, oldValue, newValue -> 32 println("oldValue: ${oldValue.toInt()}, newValue: ${newValue.toInt()}") 33 } 34 } 35 } 36}