2

How can I add custom css properties like -fx-accent or -fx-base.

I've tried a naive way:

.root {
    -fx-small: 20;
}

.button {
    -fx-font-size: -fx-small;
}

Unfortunaly, I've got:

WARNING: com.sun.javafx.css.parser.CSSParser declaration CSS Error parsing file:/home/ark/Projects/FXTest/out/production/FXTest/a.css: Expected '< number>' while parsing '-fx-font-size' at [6,15]

DontVoteMeDown
  • 21,122
  • 10
  • 69
  • 105
Arkady Rost
  • 357
  • 2
  • 4
  • 9
  • Are you trying to create a variable -fx-small that equals 20? You may consider looking into LESS instead of CSS. It allows for variable declaration so you could do this. – johnsoe Nov 27 '13 at 20:08
  • Maybe, but I'm looking for the way javafx handle it. I need to find out how -fx-accent property is set in caspian.css. – Arkady Rost Nov 27 '13 at 20:38
  • [Related question](http://stackoverflow.com/questions/13566210/declaring-variable-in-javafx-css-file) says only colors are allowed as variables in css. Use something like LESS as mentioned – brian Nov 28 '13 at 14:31

2 Answers2

0

I never use the -fx prefix for global definitions. For me it is working like it is shown on slide 32: http://de.slideshare.net/ClaudineZillmann/lets-get-wetbestpracticesforskinningjavafxcontrols

Maybe there is a bug with the number format. Have you tried 20.0 ?

Hendrik Ebbers
  • 2,570
  • 19
  • 34
0

The JavaFX custom CSS-Variables does not support numbers!
You can just define custom colors.

.root {
    -fx-color: red;
}

.button {
    -fx-background-color: -fx-color;
}

Sry bro, maybe in a future release..
Happy coding,
Kalasch

Kalaschni
  • 2,301
  • 24
  • 37