1

我正在使用 JFXtras 的日历,默认情况下,事件有 24 个组(类别),我想更改它们。这是默认代码:

public final static List<AppointmentGroup> DEFAULT_APPOINTMENT_GROUPS = IntStream.range(0, 24)
        .mapToObj(i -> new Agenda.AppointmentGroupImpl()
              .withStyleClass("group" + i)
              .withDescription("group" + (i < 10 ? "0" : "") + i))
        .collect(Collectors.toList());

final public static List<String> CATEGORIES = IntStream.range(0, 24)
        .mapToObj(i -> new String("group" + (i < 10 ? "0" : "") + i))
        .collect(Collectors.toList());
4

2 回答 2

1

好吧,约会告诉议程它属于哪个组。该 AppointmentGroup 提供了要使用的 CSS 类(用于设置组中所有约会的样式)。所以 24 个预定义组就在那里,因为在 Agenda.css 中有一个相关的定义。

https://github.com/JFXtras/jfxtras/blob/8.0/jfxtras-agenda/src/main/resources/jfxtras/internal/scene/control/skin/agenda/Agenda.css 第71行

.group0 { -fx-background-color: #AC725E; -fx-fill: #AC725E; }
.group1 { -fx-background-color: #D06B64; -fx-fill: #D06B64; }
.group2 { -fx-background-color: #F83A22; -fx-fill: #F83A22; }
...

因此,如果您创建一个新的 AppointmentGroup 类,设置一个样式类 id(不要使用现有的 id,如“group0”,就像上面代码中所做的那样,这有点没用),然后将该 AppointmentGroup 分配给一个 Appointment、Agenda将使用样式类呈现它。然后,您当然需要在 CSS 文件中定义它。

您还可以覆盖现有 group0、group1、...的样式

于 2017-06-21T19:07:47.083 回答
0

给个思路。。

1:加载你的css文件

vbox_root.getStylesheets().add("/styles/styles.css");

2:新增AppointmentGroups

agenda.appointmentGroups().add(new Agenda.AppointmentGroupImpl().withDescription("group24").withStyleClass("group24"));
agenda.appointmentGroups().add(new Agenda.AppointmentGroupImpl().withDescription("group25").withStyleClass("group25"));
agenda.appointmentGroups().add(new Agenda.AppointmentGroupImpl().withDescription("group26").withStyleClass("group26"));
agenda.appointmentGroups().add(new Agenda.AppointmentGroupImpl().withDescription("group27").withStyleClass("group27"));

3:在styles/styles.css中定义你的风格

.group24 {
    -fx-background-color: #424242;
    -fx-fill: #424242;
}

.group25 {
    -fx-background-color: #CDCDCD;
    -fx-fill: #CDCDCD;
}

.group26 {
    -fx-background-color: #000000;
    -fx-fill: #000000;
}

.group27 {
    -fx-background-color: #000000;
    -fx-fill: #000000;
}
于 2018-11-22T16:42:46.463 回答