Question

For performance reasons I would like to disable CSS styling for some of my nodes. I have several thousands of them and I would really like to simply fill them with a solid background color, so not much need for CSS. Is it enough to remove all style classes from them? I tried this and after profiling I noticed that processCSS() still consumes most of the CPU time.

Dirk

Was it helpful?

Solution

There is no way to inherently remove all css from javafx nodes (that I know of) since all javafx items ship with a default .css file that users simply override to add they're own spin on the various css parameters. (the default is called caspian.css (for Javafx 2.*) and Modena.css( for Javafx 8.0 +)). Although you could programmatically change the background color of each node when it gets created so you don't have to load a whole NEW .css file for every single node, there would still be some loading of the default .css for each node created.

OTHER TIPS

No, removing all style classes is not enough to disable CSS. The default .css file will be processed in that case. Although currently not really related to CSS rendering, processCss takes time because the said method can be as complex as the max number of children of your nodes, which can be as many as several thousands like you said. If it's alright for you to override caspian.css to make it simpler, then I suggest that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top