JavaFX CSS Parser错误预期COLON

sie*_*y22 3 css java javafx

所以我得到了一个错误,我不知道该怎么解决因为从我的观点来看,一切都很好:

CSS代码:

@font-face {
    font-family: 'Titillium';
    font-style: normal;
    font-weight: normal;
    src: url('Titillium.ttf');
}

.root{
    -fx-font-family: "Titillium";
}

.label{
    -fx-font-size: 14pt;
}

.title {
    -fx-font-size: 24pt;
}

.textfield{
    -fx-font-size: 15pt;
}

.list-cell{
    -fx-font-size: 15pt;
}

.combo-box{
    -fx-font-size: 12pt;
}

#detaillist .list-cell{
    -fx-background-color: transparent;
}

#subtitle{
    -fx-font-size: 10pt;
}
Run Code Online (Sandbox Code Playgroud)

和我设置Sytle的Java代码:

title = new Label("Notiz vom " + Selector.getSelectedNotiz().getDatum().toLocaleString());
title.setTextFill(Color.BLACK);
//--------------- Right here ----------------------
title.setStyle("title");
cmbLernender = new ComboBox<String>();
k = new Label("Kompetenz");
k.setTextFill(Color.BLACK);
Run Code Online (Sandbox Code Playgroud)

看起来很好......

现在,如果我开始它会发生:

Sep 15, 2014 1:25:30 PM com.sun.javafx.css.parser.CSSParser declaration
WARNUNG: CSS Error parsing '*{title}: Expected COLON at [1,7]
Run Code Online (Sandbox Code Playgroud)

谢谢您的帮助.

和平

Ita*_*iha 9

您正在尝试设置styleclassLabel 标题.如果要设置styleclass使用:

title.getStyleClass().add("title");
Run Code Online (Sandbox Code Playgroud)

如果要直接向控件添加样式,而不是从css/styleclass加载样式,可以使用:

title.setStyle("-fx-background-color: slateblue; -fx-text-fill: white;");
Run Code Online (Sandbox Code Playgroud)