noobProgrammer
noobProgrammer

Reputation: 477

CSS doesn't have effect on JavaFX GUI

My CSS code isn't doing anything to the look of the elements for the JavaFX application I have. I've noticed that the lines of code in the CSS document say "Unknown property" and are highlighted in yellow. I tried to uninstall and then reinstall e(fx)clipse but that didn't help. Here's the code

CSS

.header-one {
    -fx-stroke-width: 4;
    -fx-fill: 99000;
}

Java

Label patronHeader = new Label("Current Patron");
patronHeader.getStyleClass().add("header-one");

What should I do to fix the problem?

Upvotes: 1

Views: 104

Answers (2)

James_D
James_D

Reputation: 209358

-fx-stroke-width and -fx-fill are not supported CSS properties for a Label.

You need

.header-one {
    -fx-text-fill: #990000 ;
}
.header-one .text {
    -fx-stroke-width: 4 ;
}

Upvotes: 0

aw-think
aw-think

Reputation: 4803

In your case, you use css elements, that a Label does not support:

Visit this site for more information on what you can set on Labeled controls: http://docs.oracle.com/javase/8/javafx/api/javafx/scene/doc-files/cssref.html#labeled

Upvotes: 2

Related Questions