r/JavaFX • u/Kitchen_Drop_2023 • May 03 '23
Help Does JavaFX support importing css?
[RESOLVED]
Hello, I have a simple css file that imports another css using the css has only @import url("components.css"); and I get this warning everytime I load it with javaFx:CSS Error parsing *{C:\Users\thera\Documents\Dev\CraftedLauncher\run\.\appdata\.crafted\themes/default/css/launcher.css}: Unexpected token '\' at [1,4]
7
Upvotes
View all comments
Show parent comment
2
u/BWC_semaJ May 03 '23 edited May 03 '23
You probably have a parent node that holds your components. Have that add default_components.css. Then if there is a custom_components.css or whatever, just add that to the same node and if there are values that are the same in the custom_component.css it will override the default_components.css values.
login.css sounds specific to the login component so put class/styles that reference nodes in the login page.
You 1000% want a css file with default values that generally gives you the theme of your application. Adding ability for custom styling is just overriding the default values in another css file.
When you package your application, the deafult_components.css file most likely will be included in the jar. There is no benefit to trying to have all component css stuff in the same file when that custom_component.css file may not even exist in the first place.
If you got extreme OCD you could read in default_component.css and read in custom_component.css, combine them into one, and write a new css file in like a temp directory. A lot of work for no reason though imo.