Thursday 15 August 2013

JavaFX CSS theming via @import and variables -


I specify the variable in the colors that are repeatedly used in my Java Fx CSS and references the variable instead of the color constant Taken to:

/ P>

  * {Theme-Background Dark: # 335588; } #messageListPane {-fx-background-color: theme-backgroundDark; }  

Now I want to move the block where I define color variable names and move it to a different CSS file. This will allow me to swap different CSS files on the runtime to change the theme of the application:

Theme1.css

  * { Theme - Background: # 335588; }  

Main.css

  @import url ("/styles/Theme1.css"); # Message ListPan {-fx-background-color: theme-backgroundDark; }  

But when I do this, JavaFX is unable to find variables at runtime:

  Warning: While solving lookup, theme background is dark 'Could not be resolved in' * # messageListPane 'in the stylesheet file by the' -fx-background-color 'rule: / C: /xxxx/styles/Main.css  

This is not a problem with @import statement; I have other @import that define class selectors and they just pick up in Main.css . It looks like the wildcard selector * {...} . There is something to do with .

So why did a wildcard selector in the same CSS designate color variables, but not imported from another CSS?

The designated colors are fine. My @import statement is being ignored, it's as simple as if I attach themes.css manually via code, named colors are visible. @import statement is not picking the theme file and I am not giving any kind of error, I will open another question for that.


1 comment: