Hi,
@rwblinn
How can I change the font size in the dialogues presented in the post?
This is not possible without making (significant) changes to the library.
The library makes (mostly) use of the standard JavaFX dialogs.
An option to style these standard dialogs, is to use an external style sheet with style classes (see below example).
Because the library core is developed with Inline Java, each of the methods has to be changed.
Recommendations
Look at the
B4XDialogs as part of the XUI Views instead
OR
if you want to create your own simple dialogs, look at this example:
[CODE lang="b4x" title="B4J Example Customized Alert Dialog Type Information"]
#Region Project
' B4JHowTo AlertDialogStyle
' Style the standard JavaFX Alert dialog by using an external stylesheet.
' 20221117 rwbl
#End Region
#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private xui As XUI
Private Button1 As B4XView
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1")
MainForm.Show
Button1_Click
End Sub
Sub Button1_Click
AlertDialogEx("Title", "Header", $"Content${CRLF}${CRLF}More..."$)
End Sub
'Alert Dialog type INFORMATION with styling for the dialogpane.
'The style is defined in an external stylesheet AlertDialog.css.
Sub AlertDialogEx(title As String, header As String, content As String)
Dim joAlert As JavaObject
Dim joAlertType As JavaObject
'Init the AlertType Enum Class
joAlertType.InitializeStatic("javafx.scene.control.Alert.AlertType")
'Get the AlertType INFORMATION used to set the Alert Dialog type
Dim joAlertTypeInfo As JavaObject = joAlertType.RunMethod("valueOf", Array("INFORMATION"))
'Create a new instance of the Alert Dialog as INFORMATIONType
joAlert.InitializeNewInstance("javafx.scene.control.Alert", Array(joAlertTypeInfo))
'Styling - Load the external stylesheet "AlertDialog" located in the files folder.
Dim joDialogPane As JavaObject = joAlert.RunMethod("getDialogPane", Null)
joDialogPane.RunMethodJO("getStylesheets", Null).RunMethodJO("add", Array(File.GetUri(File.DirAssets, "AlertDialog.css")))
'Add the style class
joDialogPane.RunMethodJO("getStyleClass", Null).RunMethodJO("add", Array("AlertDialog"))
'Set alert text for the title, header, content
joAlert.RunMethodJO("setTitle", Array As String(title))
joAlert.RunMethod("setHeaderText", Array As String(header))
joAlert.RunMethod("setContentText", Array As String(content))
'Show the alert dialog and wait for the OK button to be pressed
If joAlert.RunMethodjo("showAndWait", Null).RunMethod("isPresent", Null)=True Then
Log("Dialog closed with OK")
End If
End Sub
[/CODE]
[CODE lang="html" title="AlertDialog External Stylesheet"]// Dialog background color
.AlertDialog{
-fx-background-color: #FFFFFF;
}
// Header panel
.AlertDialog:header *.header-panel{
-fx-background-color: #0000FF;
}
// Header label
.AlertDialog:header *.header-panel *.label{
-fx-font-size: 18px;
-fx-font-style: italic;
-fx-text-fill: #FFFFFF;
-fx-font-weight: bold;
}
// Content label
.AlertDialog > *.label.content{
-fx-font-size: 18px;
-fx-font-weight: normal;
}
// Button bar
.AlertDialog > *.button-bar > *.container{
-fx-background-color: #D3D3D3;
}
[/CODE]