自定义ControlsFX通知 [英] Customize ControlsFX Notifications
问题描述
我想使用
让我使用它我想成为能够自定义通知的颜色和其他一些样式。有没有人知道我该怎么做?
编辑:
通过设置 Notifications.owner(...)
通知的样式与我的主应用程序相同,但然后显示在主要应用程序,而不是在我的屏幕的右下角。
Notifications.create( ).title(...)。text(..)。action(...)。position(Pos.BOTTOM_RIGHT).show();
通过在Java中使用此行并在样式表底部添加以下行 ,它可以自定义通知。
.notification-bar> .pane {
-fx-background-color:red,yellow,blue;
-fx-padding:5 5 5 5;
-fx-background-insets:0,1,2;
}
.notification-bar> .pane .title {
-fx-font-size:1.333em; / * 16px; * /
-fx-text-fill:#000;
-fx-font-weight:bold;
}
.notification-bar> .pane .label {
-fx-font-size:1em; / * 12px; * /
-fx-text-fill:#000;
-fx-alignment:左上角;
}
/ ************************************ ******************************************
*
*关闭按钮
*
************************************* **************************************** /
。 notification-bar> .pane .close-button {
-fx-background-color:transparent;
-fx-background-insets:0;
-fx-background-radius:0;
-fx-padding:0 0 0 0;
-fx-alignment:center;
}
.notification-bar> .pane .close-button:悬停{
-fx-background-color:线性渐变(#a3a3a3,#8b8b8b 34%,#777777 36%,#777777 63%,#8b8b8b 65%,#addad) ;
}
.notification-bar> .pane .close-button:press {
-fx-background-color:linear-gradient(#a3a3a3,#8b8b8b 34%, #777777 36%,#777777 63%,#8b8b8b 65%,#addad):
}
.notification-bar> .pane .close-button> .graphic {
-fx-background-color:#fff;
-fx-scale-shape:false;
-fx-padding:4.5 4.5 4.5 4.5; / *图形是9x9 px * /
}
.notification-bar> .pane .close-button:hover> .graphic {
-fx-background-color:# FFF;
}
.notification-bar> .pane .close-button:press> .graphic {
-fx-background-color:#fff;
}
.notification-bar> .pane .close-button> .graphic {
-fx-shape:
M395.992,296.758l1.794-1.794 l7.292,7.292l-1.795,1.794 L395.992,296.758z M403.256,294.992l1.794,1.794l-7.292,7.292l-1.794-1.795 L403.256,294.992z;
}
I want to use ControlsFX Notifications class, as JavaFX seems to doesn't offer anything like it (or does it?).
For me to use it I want to be able to customize the color of the notification and some other styles. Does anybody have an idea of how I can do that?
Edit:
Through setting Notifications.owner(...)
the notification is styled the same way as my main application, but it is then shown within the main application as well and not at the bottom right corner of my screen.
Notifications.create().title(...).text(..).action(...).position(Pos.BOTTOM_RIGHT).show();
Through using this line in Java and adding following lines at the bottom of my stylesheet it was able to customize the notification.
.notification-bar>.pane {
-fx-background-color: red, yellow, blue;
-fx-padding: 5 5 5 5;
-fx-background-insets: 0, 1, 2;
}
.notification-bar>.pane .title {
-fx-font-size: 1.333em; /*16px;*/
-fx-text-fill: #000;
-fx-font-weight: bold;
}
.notification-bar>.pane .label {
-fx-font-size: 1em; /*12px;*/
-fx-text-fill: #000;
-fx-alignment: top-left;
}
/******************************************************************************
*
* Close button
*
*****************************************************************************/
.notification-bar>.pane .close-button {
-fx-background-color: transparent;
-fx-background-insets: 0;
-fx-background-radius: 0;
-fx-padding: 0 0 0 0;
-fx-alignment: center;
}
.notification-bar > .pane .close-button:hover {
-fx-background-color: linear-gradient(#a3a3a3, #8b8b8b 34%, #777777 36%, #777777 63%, #8b8b8b 65%, #adadad);
}
.notification-bar>.pane .close-button:pressed {
-fx-background-color: linear-gradient(#a3a3a3, #8b8b8b 34%, #777777 36%, #777777 63%, #8b8b8b 65%, #adadad):
}
.notification-bar>.pane .close-button>.graphic {
-fx-background-color: #fff;
-fx-scale-shape: false;
-fx-padding: 4.5 4.5 4.5 4.5; /* Graphic is 9x9 px */
}
.notification-bar>.pane .close-button:hover>.graphic {
-fx-background-color: #fff;
}
.notification-bar>.pane .close-button:pressed>.graphic {
-fx-background-color: #fff;
}
.notification-bar>.pane .close-button>.graphic {
-fx-shape:
"M395.992,296.758l1.794-1.794l7.292,7.292l-1.795,1.794 L395.992,296.758z M403.256,294.992l1.794,1.794l-7.292,7.292l-1.794-1.795 L403.256,294.992z";
}
这篇关于自定义ControlsFX通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!