Is there a way to change the built-in controlfx notification popup color?

 ̄綄美尐妖づ 提交于 2020-01-07 04:22:49

问题


[Edit] here is an exemple of use of the notification popup I'm talking about:

Notifications.create().title(...).text(...).hideAfter(Duration).show();

in this case the notification popup follow the modena style (a little bit gray)

if we add dark style like this:

Notifications.create().darkStyle().title(...).text(...).hideAfter(Duration).show();

It's shown with dark color

So I just want to know if there is a way to change these default style, I already know about the notification pane and I am not talking about it.

So please I made my homework and did some research ... I found nothing that's why I here to find help


回答1:


Take a look at the documentation: https://controlsfx.bitbucket.io/org/controlsfx/control/NotificationPane.html

You can take a look at the CSS file for the notification pane here: /org/controlsfx/control/notificationpane.css

Now you can use the CSS classes in your own stylesheet.




回答2:


Here is how I did:

  • I added a new css file named notificationpopup.css as Phil mentionned (thanks to him)

  • inside that file i maked changes I added the css file to my primaryStage

  • set the owner of my notification popup to this stage And it works well now !

String css = this.getClass().getResource("/views/notificationpopup.css").toExternalForm();
//as my css are in a views package

primaryStage.getScene().getStylesheets().add(css);
Notifications.create().owner(primaryStage).text("my message").hideAfter(new Duration(2000)).showInformation();

If you want an example of the notificationpopup.css to make your own visit the repository of controlfx

Thanks to Phil and the community for the help



来源:https://stackoverflow.com/questions/44710401/is-there-a-way-to-change-the-built-in-controlfx-notification-popup-color

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