问题描述
我正在使用ControlsFX通知来显示一组消息.文本对我来说不是完美的方式,所以我在TableView中显示数据.
I am using ControlsFX Notification to display a group of messages. Text is not perfect way for me, so I present data in TableView.
import org.controlsfx.control.Notifications;
......
TableView<NotificationModel> notificationTable = new TableView();
......
Notifications notification = Notifications.create()
.title("Transaction Notifications")
.text(null)
.graphic(notificationTable)
.position(Pos.BOTTOM_RIGHT)
.hideAfter(Duration.minutes(1));
notification.show();
通常情况下,通知如下所示:
In normal case, notification looks like this:
但是,大多数情况下,通知似乎已损坏,如下所示.似乎显示> 1条通知,彼此重叠.
But notification appears corrupted most of the time, as below. It seems showing > 1 Notification, overlaying on each other.
我测试了ControlsFX示例jar文件,选择图形选项:总替换图形".它显示出相同的损坏行为.
I tested ControlsFX sample jar file, choosing "Graphic Options: Total-replacement graphics". It shows same corrupted behaviour.
当显示带有图形的非文本通知时,它看起来像是ControlsFX的一个错误.有人遇到类似的问题吗?我正在macOS Sierra 10.12.2,ControlsFX 8.40.12上开发.
It looks like a bug from ControlsFX, when showing non-text notification with graphics. Anyone facing similar issue? I am developing on macOS Sierra 10.12.2, ControlsFX 8.40.12.
推荐答案
我通过将TableView包裹在AnchorPane中,然后设置为通知的图形来解决了问题.
I got my problem fixed by wrapping TableView in AnchorPane, then set as graphic of Notifications.
AnchorPane anchorPane = new AnchorPane(notificationTable);
Notifications notification = Notifications.create()
.title("Transaction Notifications")
.text(null)
.graphic(anchorPane)
.position(Pos.BOTTOM_RIGHT)
.hideAfter(Duration.minutes(1));
notification.show();
我从这里得到了提示: ControlsFX问题跟踪器
I got the hint from here: ControlsFX Issue Tracker
这篇关于ControlsFX通知图形已损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!