This content has been marked as final. Show 5 replies
You can't provide a string in place of an external style sheet.1 person found this helpful
You can set the style on an individual node using setStyle(...). That will only affect the node on which you call the method, and you can't use selectors inside it.
The closest equivalent to what you are trying to do would be something like
A better solution may be to define the possible styles in an external style sheet, using different (logical) class names, and to dynamically change the style class of the control. (This relies on knowing all possible styles you may want to use, which of course may not be the situation you're in.)
Node titledPane = c.lookup(".titled-pane"); titledPane.setStyle(" -fx-text-fill: red; -fx-collapsible: false; ");
Many thanks for your reply.
My problem with the solution you suggested me is that:
1 - c.lookup(".titled-pane") return a null pointer. I read that the Node must be shown before lookup may return the child node...
2 - I will need to specify the style for every child node, which can be a bit complicated depending on the node...
I am developing an application where some "super" users must be able to customize the interface, and since I am building a jar file running as applet, I cannot modify stylesheet files before applying them. As a result, I have to rebuild the jar to change the css files... I do not sea the advantage of CSS if I cannot update if dynamically without rebuilding the application.
Thanks for your help.
Assuming your applet is signed, you could write the css to a file on the filesystem. Then, on a Scene or Parent (or subclass) you can call getStylesheets().add(...) and pass in a URL mapping to the file ("file://path.to.css").1 person found this helpful
Ah yes, I tested this but I did provide a file path without file://
I will try this and poste the result.
Many thanks for your help.
the solution you suggested me works perfectly.
Thanks a lot.