gpt4 book ai didi

java - 自定义 ControlsFX 通知

转载 作者:行者123 更新时间:2023-12-03 02:49:21 25 4
gpt4 key购买 nike

我想使用ControlsFX Notifications类,JavaFX 似乎没有提供类似的东西(或者确实有?)。

Notification by ControlsFX

对于我来说,我希望能够自定义通知的颜色和其他一些样式。有人知道我该怎么做吗?

编辑:

通过设置 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: 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";
}

关于java - 自定义 ControlsFX 通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33494089/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com