Skip to content

Instantly share code, notes, and snippets.

@jiro4989
Last active July 6, 2021 16:01
Show Gist options
  • Save jiro4989/9e55bf86c944adf489d9cbbabc306d07 to your computer and use it in GitHub Desktop.
Save jiro4989/9e55bf86c944adf489d9cbbabc306d07 to your computer and use it in GitHub Desktop.
KotlinでJavaFXのListViewに独自データクラスを追加して、表示されるテキストを変更する方法
// この例ではFileのデータを持つ
listView.cellFactory = Callback<ListView<File>, ListCell<File>> {
object : ListCell<File>() {
override fun updateItem(item: File?, empty: Boolean) {
super.updateItem(item, empty)
if (item != null) text = item.name
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment