JavaFX表单元格格式 [英] JavaFX Table Cell Formatting

查看:140
本文介绍了JavaFX表单元格格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  TableColumn< Event,Date> releaseTime = new TableColumn<>(Release Time); 
releaseTime.setCellValueFactory(
new PropertyValueFactory< Event,Date>(releaseTime)
);

如何更改releaseTime的格式?目前它在Date对象上调用一个简单的toString。

解决方案

你可以通过Cell Factories来完成。请参阅

https://stackoverflow.com/a/10149050/682495

https://stackoverflow.com/a/10700642/682495

虽然第二个链接是大约 ListCell ,同样的逻辑也完全适用于 TableCell s。

如果你需要一些示例代码,请点击这里。

    TableColumn<Event,Date> releaseTime  = new TableColumn<>("Release Time");
    releaseTime.setCellValueFactory(
                new PropertyValueFactory<Event,Date>("releaseTime")
            );

How can I change the format of releaseTime? At the moment it calls a simple toString on the Date object.

解决方案

You can accomplish that through Cell Factories. See
https://stackoverflow.com/a/10149050/682495
https://stackoverflow.com/a/10700642/682495
Although the 2nd link is about ListCell, the same logic is totally applicable to TableCells too.

P.S. Still if you need some sample code, kindly will attach here.

这篇关于JavaFX表单元格格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆