tornadofx格式化listview中的item-LMLPHP


class ListView : View() {
    val responses = FXCollections.observableArrayList<Student>()
    override val root = vbox {
        listview(responses) {
            cellFormat {
                graphic = cache {
                    form {
                        fieldset {
                            label(it.name) {
                                alignment = Pos.CENTER_RIGHT
                                style {
                                    fontSize = 22.px
                                    fontWeight = FontWeight.BOLD
                                }
                            }
                            field("address:") {
                                label(it.address)
                            }
                        }
                    }
                }
                onUserSelect(1) {
                    //                    println(it)
                }
            }
        }
        var id = 0
        button("Add Item").action {
            responses.add(Student("Student${id}",
                    "address${id}"))
            id++
        }
    }
}

class Student(val name: String, val address: String) {
    override fun toString(): String {
        return "Student(name=${name},address=${address})"
    }
}
07-15 12:40