JavaFX17 added the possibility to use inlineURIs. One use for this is to add small CSS Stylesheets from code:
Simple to use and very useful for libraries where you would otherwise need to add a stylesheet to the Files directory.
DependsOn :
B4X:
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1")
MainForm.Show
MainForm.Stylesheets.Add(GetDataURI(StyleSheet))
End Sub
Private Sub StyleSheet As String
Return $"
.button{
-fx-background-color:green;
}"$
End Sub
Private Sub GetDataURI(Data As String) As String
Dim SU As StringUtils
Return "data:text/css;base64," & SU.EncodeBase64(Data.GetBytes("UTF-8"))
End Sub
DependsOn :
- JavaFX 17+
- jStringUtils (Internal library)
Last edited: