compile 'no.tornado:tornadofx:1.7.17'
compileKotlin { kotlinOptions.jvmTarget = "1.8" }
import javafx.application.Application import tornadofx.* class App:tornadofx.App(MainView::class,MainStylesheet::class) class MainView:View() { override val root = vbox { label("Hello World") } } class MainStylesheet:Stylesheet() { init { label { fontSize = 20.px } } } fun main(args:Array<String>) { Application.launch(App::class.java,*args) }
import javafx.application.Application import javafx.collections.FXCollections import tornadofx.* class App:tornadofx.App(MainView::class,MainStylesheet::class) class Person(id: Int, name: String) { var id: Int by property(id) var name: String by property(name) } class MainView:View() { private val persons = FXCollections.observableArrayList( Person(10, "Ant"), Person(20, "Bee"), Person(30, "Cat") ) override val root = tableview(persons) { column("ID", Person::id) column("name", Person::name) } } class MainStylesheet:Stylesheet() { init { label { fontFamily = "Noto Sans CJK SC Medium" fontSize = 20.px } } } fun main(args:Array<String>) { Application.launch(App::class.java,*args) }
注意:
文章首发: https://baijifeilong.github.io