6

so I got an error and I don't know what to fix cuz from my point of view there's everything allright:

CSS Code:

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

and the Java Code where I set the Sytle:

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

this looks fine...

now if I start it this happens:

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

thanks for the help.

Peace

1 Answer 1

14

You are trying to set a styleclass to Label title. When you want to set styleclass use :

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

If you want to add styles directly to your control, instead of loading them from a css/styleclass, you can use :

title.setStyle("-fx-background-color: slateblue; -fx-text-fill: white;");
Sign up to request clarification or add additional context in comments.

3 Comments

Isn't the real problem the useage of "@font-face" which is not supported in javafx?
@font-face has no effect whatsoever. The problem is the way styleclass is being added to the Label
@tomsontom is right, the error is a css parse error. it was supported from javafx8:docs.oracle.com/javase/8/javafx/api/javafx/scene/doc-files/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.