JavaFX in-memory dynamic CSS file editing and applying

David Grieve david.grieve at oracle.com
Mon Oct 15 12:02:10 UTC 2018


Just setStyle -fx-theme-header (etc.) on the root node.


On 10/15/18 1:05 AM, Ty Young wrote:
> Does JavaFX have an API for dynamically editing and applying CSS files 
> in-memory? If not, would there be any possibility in one ever being made?
>
>
> My reasoning for such an API is, instead of switching between 
> completely separate CSS files and having to update each whenever I 
> need to support a new component, I'd like the ability to just have 1 
> CSS file and edit it's values in-memory and have it reflected in 
> JavaFX as soon as the change is made. For example instead of changing 
> the individual components themselves I'd like to get all of this:
>
>
> *
> {
>     -fx-theme-header: #444444;
>     -fx-theme-background: #3D3D3D;
>     -fx-theme-background-alt: #2E2E2E;
>     -fx-theme-selected: #F0544C;
>     -fx-theme-label-text: #D2D2D2;
>     -fx-theme-selectable-hover: #454545;
>     -fx-theme-tab-close-color: -fx-theme-label-text;
>
>     -fx-highlight-fill: -fx-theme-selected;
> }
>
>
> and modify it via a JavaFX API to change it to something like:
>
>
> *
> {
>     -fx-theme-header: #FFFFFF;
>     -fx-theme-background: -fx-theme-header;
>     -fx-theme-background-alt: #F2F2F2;
>     -fx-theme-selected: #CBEAFF;
>     -fx-theme-label-text: #333333;
>     -fx-theme-selectable-hover: #E1E1E1;
>     -fx-theme-tab-close-color: -fx-theme-label-text;
>
>     -fx-highlight-fill: -fx-theme-selected;
> }
>
>
> Since these are used throughout the CSS file, all the components that 
> use these will be updated.
>
>
>
>
>



More information about the openjfx-dev mailing list