Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javafx.application.Application
- import javafx.scene.control.Button
- import javafx.scene.layout.VBox
- import tornadofx.*
- import java.time.LocalDate
- import java.time.Period
- class Person(id: Int, name: String, birthday: LocalDate) {
- var id by property(id)
- fun idProperty() = getProperty(Person::id)
- var name by property(name)
- fun nameProperty() = getProperty(Person::name)
- var birthday by property(birthday)
- fun birthdayProperty() = getProperty(Person::birthday)
- val age: Int get() = Period.between(birthday, LocalDate.now()).years
- }
- private val persons = listOf(
- Person(1,"Samantha Stuart",LocalDate.of(1981,12,4)),
- Person(2,"Tom Marks",LocalDate.of(2001,1,23)),
- Person(3,"Stuart Gills",LocalDate.of(1989,5,23)),
- Person(3,"Nicole Williams",LocalDate.of(1998,8,11))
- ).observable()
- class MyView : View() {
- override val root = VBox()
- init {
- with(root) {
- Button("Press Me")
- Button("Foo")
- tableview(persons) {
- isEditable = true
- column("ID",Person::id).makeEditable()
- column("Name", Person::name).makeEditable()
- column("Birthday", Person::birthday).makeEditable()
- column("Age", Person::age)
- }
- }
- }
- }
- class MyApp: App(MyView::class)
- fun main(args: Array<String>) {
- Application.launch(MyApp::class.java, *args)
- }
Advertisement
Add Comment
Please, Sign In to add comment