JavaFX的。 如何使用FXML编辑TableViewCell?
我想只使用fxml使TableViewCell。 我该怎么做。
现在我有一个模型类DuplicateFileInfo
class DuplicateFileInfo(var id: Long, var path: String, var editableField: String?) {}
我有TableView
在这种情况下,我有可编辑的表格视图。 但编辑完成后该值不会设置为模型。 是否有可能使这项工作没有codding?
感谢James_D,我可以得到结果。
与kotlin模型类应该是这样的
class DuplicateFileInfo(id: Long, path: String, shouldBeDeleted: Boolean) { private val id: LongProperty private val path: StringProperty private val shouldBeDeleted: BooleanProperty init { this.id = SimpleLongProperty(id) this.path = SimpleStringProperty(path) this.shouldBeDeleted = SimpleBooleanProperty(shouldBeDeleted) } fun getId(): Long { return id.get() } fun idProperty(): LongProperty { return id } fun setId(id: Long) { this.id.set(id) } fun getPath(): String { return path.get() } fun pathProperty(): StringProperty { return path } fun setPath(path: String) { this.path.set(path) } var isShouldBeDeleted: Boolean get() = shouldBeDeleted.get() set(shouldBeDeleted) = this.shouldBeDeleted.set(shouldBeDeleted) fun shouldBeDeletedProperty(): BooleanProperty { return shouldBeDeleted } override fun toString(): String { val sb = StringBuffer("DuplicateFileInfo{") sb.append("id=").append(id.get()) sb.append(", path=").append(path.get()) sb.append(", shouldBeDeleted=").append(shouldBeDeleted.get()) sb.append('}') return sb.toString() } }