B4J Library jRLDialogsX - Dialogs Library

micro

Well-Known Member
Licensed User
Longtime User
Hi rwblinn
How I change the icon present on dialog form?
The icon is different, it's not the same as I chose from the designer.
Thanks
 

rwblinn

Well-Known Member
Licensed User
Longtime User
Hi rwblinn
How I change the icon present on dialog form?
The icon is different, it's not the same as I chose from the designer.
Thanks
The library makes use of the standard JavaFX Dialogs.
To change the icon, inline Java needs to be changed - which is quite a task for all the dialogs.
In the source code, see method
B4X:
public static Map.MyMap LoginDialog2
for an example.

Please note, as mentioned in post #79, I am not maintaining this library anymore.

Recommendation: Instead this library, use dialogs from the standard XUI library or develop own dialogs class(es) derived from the standard libraries.
 

rwblinn

Well-Known Member
Licensed User
Longtime User
Update v1.87 (see Post #1)

  • NEW: SimpleFormDialog - DatePicker via option "D"
  • NEW: YesNoCancel dialog - if Cancel text is empty, the cancel button is not created
  • NEW: ListDialog, ListDialog2 - if DefaultItem = -1 then no item selected
  • NEW: ListFindDialog Set or get content of textfield FindItem
  • UPD: Documentation & Examples
  • NEW: Published on GitHub
Note
Although had stopped developing this library further, decided to make few changes and publish on GitHub.
Again, source code of the library is included, feel free to amend further BUT consider to make use of the newest [B4X] XUI libraries (Views, Dialogs).
This library is developed using B4J v731 with JDK 1.8.0_202
 

rwblinn

Well-Known Member
Licensed User
Longtime User
is it possible to set text font, alignment, size properties displayed via Dlg.MessageDialog()? tia
This is not possible. Consider using the MessageHTMLDialog or create your own using B4XDialogs from the XUI Views Library.
B4X:
MessageHTMLDialog(Title As String, Content As String)
Title - string to show in the title bar. Content - string with HTML formatted content in an expanded web view.
Example Code Snippet
B4X:
Private Dlg As DialogsX

Dlg.Initialize
Dlg.SetParentWindow(MainForm)
Dlg.OKButtonText = "Close"
Dlg.MessageHTMLDialogShowLessDetailsText = "Show Less..."
Dlg.MessageHTMLDialogShowMoreDetailsText = "Show More..."
Dlg.MessageHTMLDialogDialogExpanded = True
Dim msg As String = "<html><h1>Test Message</h1><hr><p>This is the content. Select OK or cancel to proceed.</p></html>"
Dlg.MessageHTMLDialog("jRLDialogsX Library MessageHTMLDialog example", msg)
nice library
Thanks, Appreciated.
 
Last edited:

T201016

Active Member
Licensed User
Longtime User
jRLDialogsX is an open source B4J Dialogs Library providing a comprehensive set of Dialogs.
Hi, @rwblinn
I have a question, how can I change the font size in the dialogues presented in the post?
A little example would be nice here.
 

rwblinn

Well-Known Member
Licensed User
Longtime User
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:


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

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;
}
 

T201016

Active Member
Licensed User
Longtime User
Hello, @rwblinn

I've included a slightly reworked source code that works for my needs. I especially wanted to change the font in the description dialog and the frameless window.

Class Module DialogsX:
'Returns: Integer with Yes = 1, No = 0, Cancel = -1.
Public Sub Dialog(Title As String , Header As String, Content As String) As Int
    Return joInlineJava.RunMethod("YesNoCancelDialog", Array(Title, Header, Content))
End Sub

YesNoCancelDialog:
public static int YesNoCancelDialog(String mtitle, String mheader, String mcontent) {
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle(mtitle);
    alert.setHeaderText(mheader);
    alert.initStyle(StageStyle.TRANSPARENT);
    alert.getDialogPane().setStyle("-fx-background-color: #e2e2e2; -fx-border-color: DarkSlateGray; -fx-border-width: 2; -fx-border-radius: 0;");
    
    Label lbl = new Label(mcontent);
    lbl.setAlignment(Pos.CENTER_LEFT);
    lbl.setStyle("-fx-font-size: 13px;");
    lbl.setWrapText(true);
    alert.getDialogPane().setContent(lbl);

    ButtonType buttonTypeYes = new ButtonType(mYesButtonText, ButtonBar.ButtonData.YES);
    ButtonType buttonTypeNo = new ButtonType(mNoButtonText, ButtonBar.ButtonData.NO);
    if(!mCancelButtonText.isEmpty()) {
        ButtonType buttonTypeCancel = new ButtonType(mCancelButtonText, ButtonBar.ButtonData.CANCEL_CLOSE);
        alert.getButtonTypes().setAll(buttonTypeYes, buttonTypeNo, buttonTypeCancel);
    } else {
        alert.getButtonTypes().setAll(buttonTypeYes, buttonTypeNo);
    }
    alert.initOwner(parentWindow);
    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == buttonTypeYes){
        return 1;
    } else if (result.get() == buttonTypeNo) {
        return 0;
    } else {
        return -1;
    }
};
 

rwblinn

Well-Known Member
Licensed User
Longtime User
Update v1.88 (see Post #1)
  • NEW: Set button CSS style - Example: Dlg.OKButtonStyle = "-fx-font-size: 24px;-fx-background-color: indianred;"
  • NEW: AlertSelectionDialog - Alert dialog with buttons selection option
  • NEW: CustomAlertDialog - Hightly configurable alert dialog
  • UPD: Documentation & Examples
Note
Although stopped developing this library further, got inspired by post #88 (thanks for the trigger) .
Again, source code of the library is included, feel free to amend.
This library is developed using B4J 9.80 (64 bit) and Java JDK 11.

Example CustomAlertDialog


CustionAlertDialog - Warning:
Private Sub WarningDialog
    Dim DialogStyle As String = "-fx-background-color: navy; -fx-border-color: DarkSlateGray; -fx-border-width: 2; -fx-border-radius: 0;"
    Dim HeaderStyle As String = "-fx-background-color: #FFFF00; -fx-font-style: italic; -fx-font-size: 24px;-fx-text-fill: #FF0000; -fx-font-weight: bold;"
    Dim ContentStyle As String = "-fx-background-color: white; -fx-font-size: 33px;-fx-text-fill: #0000FF; -fx-font-weight: bold;"
    Dlg.CustomAlertDialog("WARNING", "Title", "Warning", $"Content${CRLF}..."$, -1, -1, "UTILITY", DialogStyle, HeaderStyle, ContentStyle, "OK", "", "", "-fx-background-color: #FF0000; -fx-text-fill: #FFFFFF; -fx-font-weight: bold;", "", "")
End Sub
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…