How to convert css to bss

I found this post http://docs.oracle.com/javafx/2/deployment/packaging.htm#BABCACBD

Can you tell me how can I use this tool to convert css files to bss files? From the information on the website, it's not very clear how I can use it for a JavaFX application.

Any help would be greatly appreciated.

+2
source share
2 answers

Imagine your jdk 8 home directory is on your shell path.

Create Love.java:

import javafx.stage.*; import javafx.application.*; import javafx.scene.control.*; import javafx.scene.*; public class Love extends Application { public void start(Stage stage) throws Exception { Scene scene = new Scene(new Label("hello, world")); scene.getStylesheets().add("love.css"); stage.setScene(scene); stage.show(); } } 

Compile it:

 javac Love.java 

Create love.css:

 .label { -fx-text-fill: firebrick; } 

Compile it:

 javafxpackager -createbss -srcfiles love.css -outdir . -outfile love 

This will create love.bss

Now you can delete love.css because you no longer need it because you made binary love.

Now run the application:

 java Love 

Even if you requested love.css , the JavaFX runtime was smart enough to recognize that you have the binary love.bss , and use this to apply CSS styles in your application.

love

+7
source

On Windows, I like to do this through a batch file (note that you need to have the JAVA_HOME system variable). You can create a new .bat file, copy the code below and save it. Then you can run this batch file from the same folder where your .css files are stored:

 @echo off for %%f in (*.css) do ( "%JAVA_HOME%\bin\javafxpackager" -createbss -srcfiles "%cd%\%%f" -outdir . -outfile %%~nf ) echo. echo Press any key to exit . . . pause>nul 

In principle, jewelsea explained the solution perfectly, just note that it will only work if your css file has some content in it. For example, it will not work on an empty application.css that is created by clicking e (fx), so you can just put something like .dummy-class {-fx-background-color: red;} inside and then convert it .

+1
source

Source: https://habr.com/ru/post/1243493/


All Articles