【问题标题】:JavaFX CSS Parser error Expected COLONJavaFX CSS解析器错误预期冒号
【发布时间】:2014-11-08 22:39:48
【问题描述】:

所以我遇到了一个错误,我不知道要解决什么问题,因为从我的角度来看,一切都很好:

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;
}

以及我设置 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);

这看起来不错...

现在如果我启动它会发生这种情况:

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

感谢您的帮助。

和平

【问题讨论】:

    标签: java css javafx


    【解决方案1】:

    您正在尝试将styleclass 设置为Label 标题。当你想设置styleclass 时使用:

    title.getStyleClass().add("title");
    

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

    title.setStyle("-fx-background-color: slateblue; -fx-text-fill: white;");
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-15
    • 2021-03-07
    • 2012-07-19
    相关资源
    最近更新 更多