...T
的通用类型在哪里TableView
?
到目前为止,我正在实现一个由三列组成的文件列表视图。每种类型java.nio.file.Path
。对于名称列,我编写了一个Comparator<Path>
,使用目录优先和不区分大小写的目录对文件进行排序。其他两个比较器按上次修改时间和文件大小排序。为此,他们在long
字段上进行比较。
但是comparatorProperty
列的则基于Comparator<String>
。我认为这是根据显示的文字进行排序的...
因此,我必须找到一种方法,以将“按标题排序”功能与TableView
?类型一起使用。
创建时,您使用了错误的类型参数TableColumn
。如果创建TableColumn<Path, Path>
,则可以Comparator<Path>
为该列指定。同样,TableColumn<Path, FileTime>
并TableColumn<Path, Long>
使用Comparator<FileTime>
和Comparator<Long>
。
从文档中:
Class TableColumnBase<S,T>
Type Parameters:
S - The type of the UI control (e.g. the type of the 'row').
T - The type of the content in all cells in this table column.
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句