ControlsFX Notification Graphic corrupted

大兔子大兔子 提交于 2019-12-25 06:11:24

问题


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:

But notification appears corrupted most of the time, as below. It seems showing > 1 Notification, overlaying on each other.

I tested ControlsFX sample jar file, choosing "Graphic Options: Total-replacement graphics". It shows same corrupted behaviour.

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.


回答1:


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();

I got the hint from here: ControlsFX Issue Tracker



来源:https://stackoverflow.com/questions/41559932/controlsfx-notification-graphic-corrupted

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!