B4J Library jRLDialogsX - Dialogs Library

jRLDialogsX is an open source B4J Dialogs Library providing a comprehensive set of Dialogs.
The library is coded as a B4J Class with Inline Java, no additional libraries or wrappers required.
Note: Requirements minimum B4J v5.80 and Java JDK v8 (8u40+).

Version: 1.88 - Attached the B4J library, source code, full example.

How to Use
  • Copy jrldialogsx.jar, jrldialogsxfiles.jar and xml to the B4J additional library folder.
  • In the B4J project, select jrldialogsx from the B4J IDE Libs tab.
  • See folder Examples - the fullexample is a must read, get started with the InformationDialog.
Version Control
20221122 (v1.88) NEW: Set button CSS style; AlertSelectionDialog (buttons selection); CustomAlert (hightly configurable dialog) (See Post #91)
20190407 (v1.87) NEW: SimpleFormDialog - DatePicker via option "D"; YesNoCancel dialog - if Cancel text is empty, the cancel button is not created;NEW: ListDialog, ListDialog2 - if DefaultItem = -1 then no item selected;UPD: Documentation & Examples; Published on GitHub
20180326 (v1.86) NEW: ListFindDialog Set or get content of textfield FindItem
20180312 (v1.85) NEW: DidYouKnow2 dialog with prev / next tip buttons; ExtendedDialog Show or hide the less details hyperlink button; UPD: ListFindDialog search field across dialog window, moved buttons OK & cancel down; UPD: Documentation & Examples. See Post #73
20171025 (v1.80) NEW: jRLDialogsXFiles.jar holding additional files from the library Files folder. This file must be located in the B4J Additional Libraries folder.; NEW: ListFindDialog with a find item option - first non Inline Java Dialog (requires jRLDialogsXFiles.jar); UPD: Icons (for dialogs DidYouKnow and LoginDialog2) are included in jRLDialogsXFiles.jar; UPD: LoginDialog and Login2Dialog2 with textfield horizontal grow option; UPD: Documentation & Examples. See Post #60
20170906 (v1.77) UPD: SimpleformDialog set request focus on first field; UPD: Minor changes
20170822 (v1.76) NEW: Library renamed from jRLDialogs8 to jRLDialogsX; UPD: Minor changes
20170802 (v1.75) NEW: PDF Documentation
20170711 (v1.74) NEW: SimpleFormDialog ComboBox Field with field value comma separated string, SimpleFormDialog Property ComboBox editable; UPD: Examples. See Post #60
20170703 (v1.72) NEW:ToastMessageAlert Information,Warning,Error; MessageHTMLDialog3 with OK/Cancel, MessageHTML show/hide details button; UPD: Examples. See Post #58
20170626 (v1.68) NEW:MessageDialog set wrap;SimpleFormDialog set inputfield width;MessageHTMLDialog2;Overview;UPD:Examples. See Post #56
20170620 (v1.65) NEW:Localization Show Details Hyperlink Button for Dialogs Extended, Message, MessageHTML; NEW: Extended Dialog option Message & MessageHTML Dialogs;UPD: Examples. See Post #55
20170612 (v1.62) NEW:SliderDialog; NEW:SimpleFormDialog CheckBox Field; NEW: Extended Dialog option show content expanded; NEW: DoNotAskAgainDialog; UPD: Fields padding removed; UPD: Examples. See Post #53.
20170601 (v1.59) NEW:SimpleFormDialog TextArea Field, option to split form fields; FIX: ConfirmDialog; UPD: Examples. See Post #50.
20170531 (v1.58) NEW:ToastMessage set background and border line color; UPD: Examples. See Post #49.
20170530 (v1.57) NEW:ColorNameDialog and ColorPickerDialog to get Color as Paint; NEW:ToastMessage set font size and border width; UPD:Toastmessage using default colors; UPD:Examples. See Post #47.
20170528 (v1.56) NEW:SimpleFormDialog (create n label:field pairs; field=Text or Password or Numeric); MultiInputFieldDialog (create n label:textfield pairs); IntegerInputDialog; Full Example reworked. See Post #46.
20170525 (v1.53) NEW:TimePicker (24h), TimePicker (12h), TextInputDialog4 (with option to set the width of the textfield, no label used); More examples. See Post #44.
20170522 (v1.50) NEW:String localisation Username Label/Prompt, Password Label/Prompt, OK/Cancel Button, YES/NO Button, Login Button, Select Button. See Post #42.
20160801 (v1.47) UPD:Set default selected item for ChoiceDialog, SelectDialog, ListDialog, and ListDialog2; Example 1 converted to B4J Visual Designer.
20160411 (v1.46) UPD:MessageHTMLDialog handles anchors if defined like href="#myanchor" ... name="myanchor" ...
20151011 (v1.45) UPD:Textfield gets initial focus when openeing dialog TextInputDialog, TextInputDialog2, TextInputDialog3, LoginDialog, LoginDialog2, TextAreaDialog
20150910 (v1.40) NEW:SetParentWindow; FIX: ToastMessage center screen
20150828 (v1.30) NEW:ToastMessage
20150604 (v1.20 )NEW:TextAreaDialog
20150617 (v1.11) UPD:TextInputDialog3 added hint for checking null
20150512 (v1.10) NEW:TextInputDialog3
20150406 (v1.00) NEW:SpinnerIntegerDialog, SpinnerDoubleDialog, SpinnerListDialog
20150405 (v0.90) NEW:TextInputDialog2, DatePickerDialog
20150404 (v0.80) NEW:SelectDialog; FIX: ListDialog, ListDialog2 removed expand option
20150403 (v0.70) NEW:ListDialog, ListDialog2
20150402 (v0.60) NEW:LoginDialog2, DidYouKnowDialog, ExceptionDialog, Message, MessageHTMLDialog
20150401 (v0.50) NEW:ExtendedDialog, LoginDialog
20150331 (v0.40) NEW:YesNoCancelDialog
20150330 (v0.10) NEW:First Version

Simple Example Information Dialog with localized OK Button Text
B4X:
Sub Process_Globals
  ..
  'Define the dialog using jrldialogsX
  Private Dlg As DialogsX
End Sub
Sub AppStart (Form1 As Form, Args() As String)
  ...
  'Init the dialog
  Dlg.Initialize
  'Localize (optional)
  Dlg.OKButtonText = "Thank You"
  'Use the dialog to show Information Dialog
  Dlg.InformationDialog("About", "jRLDialogX Information Dialog Example", "Hello World")
End Sub
 

Attachments

  • jRLDialogsX-188.zip
    137.2 KB · Views: 408
Last edited:

m4.s

Member
Licensed User
Longtime User
Hello Rob,

Really nice B4J library you've so generously developed, and share/support, for us.

I've downloaded, setup and am using the TextInputDialog3() method.

Before attempting to modify and rebuild the library myself, have you considered adding support to specify a larger width for the displayed input/text field? That would, of course, proportionally increase the width of the parent dialog.

As is, the hard-coded width is too small for my own needs (e.g. for the entering and editing of long URLs and local file path locations).
 

rwblinn

Well-Known Member
Licensed User
Longtime User
Update 20170522 - Post #1 lists all the methods.
NEW:Localisation of strings for Username Label/Prompt, Password Label/Prompt, OK/Cancel Button, YES/NO Button Text, Login Button Text, Select Button Text

Example
B4X:
Private Dlg As Dialogs8
Dlg.Initialize
Dlg.OKButtonText = "Thank You"
Dlg.InformationDialog("About", "jRLDialog8 Information Dialog Example", "Find more at www.rwblinn.de.")
 

m4.s

Member
Licensed User
Longtime User
Hi again Rob.

Thanks for latest update, but wondering if you saw my question submitted last Thursday (the post just preceding yours today)?
 

rwblinn

Well-Known Member
Licensed User
Longtime User
Update 20170525 - Post #1 lists all the methods.
NEW:TimePicker (24h), TimePicker (12h), TextInputDialog4 (with option to set the width of the textfield, no label used); More examples.

Example TextInputDialog4 with width set of 600, header instead of label
upload_2017-5-25_12-14-32.png


Example TimePicker24
upload_2017-5-25_12-15-24.png


Example TimePicker12
upload_2017-5-25_12-15-58.png
 

rwblinn

Well-Known Member
Licensed User
Longtime User
Update 20170528 - Full Documentation here.
NEW:SimpleFormDialog (create n label:field pairs; field=Text or Password or Numeric); MultiInputFieldDialog (create n label:textfield pairs); IntegerInputDialog; Full Example reworked.

Example SimpleFormDialog
Text Field (IP Address), Numeric Field (Port), Text Field (Username), Password Field (Password)
upload_2017-5-28_16-47-22.png

B4X:
Sub SimpleFormDialog
   'Create the list of fieldmaps
   Dim fieldlist As List
   fieldlist.Initialize
   Dim m As Map = CreateMap("id":"ipaddress", "label":"IP Address", "value":"192.168.0.99", "type":"T")
   fieldlist.Add(m)
   Dim m As Map = CreateMap("id":"port", "label":"Port", "value":"8080", "type":"N")
   fieldlist.Add(m)
   Dim m As Map = CreateMap("id":"username", "label":"Username", "value":"username", "type":"T")
   fieldlist.Add(m)
   Dim m As Map = CreateMap("id":"password", "label":"Password", "value":"password", "type":"P")
   fieldlist.Add(m)
   'Open the dialog
   Dim resultmap As Map = Dlg.SimpleFormDialog("jRLDialogs8 SimpleFormDialog", "Header", fieldlist)
   'The resultmap holds for each field the pair id:value
   If resultmap.IsInitialized Then
     Dim sb As StringBuilder
     sb.Initialize
     For i = 0 To resultmap.Size - 1
       sb.Append($"${resultmap.GetKeyAt(i)} = ${resultmap.GetValueAt(i)}"$).Append(CRLF)
     Next
     TextArea1.Text = sb.tostring
   Else
     TextArea1.Text = "User Abort"
   End If
End Sub

MultiInputFieldDialog
upload_2017-5-28_16-49-36.png
 
Last edited:

rwblinn

Well-Known Member
Licensed User
Longtime User
Update 20170530 - Full Documentation here.
NEW: ColorNameDialog and ColorPickerDialog to get Color as Paint.
NEW: ToastMessage set font size and border width.
UPD: Toastmessage using default colors.
UPD: Examples.

upload_2017-5-30_16-50-28.png
 
Last edited:

atiaust

Active Member
Licensed User
Longtime User
Hi Rob,

Great work as always.

Is it possible to change the ToastMessage background color?

Thanks
 

rwblinn

Well-Known Member
Licensed User
Longtime User
Update 20170531 - Full Documentation here.
NEW:ToastMessage set background and border line color
UPD: Examples.

ToastMessage Examples (see also in folder Examples > ToastMessage)

upload_2017-5-31_9-55-30.png


And another code example not related to the screenshots
B4X:
Dlg.ToastMessageFontSize = 32
Dlg.ToastMessageBorderWidth = 1
Dlg.ToastMessageBackgroundColor = fx.Colors.Yellow
Dlg.ToastMessageBorderColor = fx.Colors.Red
Dlg.ToastMessage("<html><h1><font color='red'><u>Welcome</u></font></h1>to jRLDialogs8</html>", 3000)
 
Last edited:

rwblinn

Well-Known Member
Licensed User
Longtime User
Update 20170601 - Full Documentation here.
NEW: SimpleFormDialog TextArea Field, option to split form fields.
FIX: ConfirmDialog.
UPD: Examples.

SimpleFormDialog (SFD)
Further developed SFD with fieldtypes supported: Text, Password, Numeric, TextArea. Created two more examples Send E-Mail and Database Add/Edit.
With few lines of code, simple dialog can be created. Localization is used to set the dialog button text based on the action required.

Example: Send EMail with fields Receipients, Subject, Body
upload_2017-6-3_10-7-51.png


Code Snippet = define the required fields, open the dialog, send the email using SMTP and wait for (requires B4J 5.51).
B4X:
Sub SimpleFormDialog
   Dim smtpEMail As SMTP   'Requires the jNet Library
   Dlg.OKButtonText = "Send"
   Dim fieldlist As List
   fieldlist.Initialize
   fieldlist.Add(CreateMap("id":"receipients", "label":"Receipients:", "value":"robert@rwblinn.de", "type":"T"))
   fieldlist.Add(CreateMap("id":"subject", "label":"Subject:", "value":"SimpleFormDialog Test", "type":"T"))
   fieldlist.Add(CreateMap("id":"body", "label":"Body:", "value":$"Line1${CRLF}Line2"$, "type":"A"))
   Dim resultMap As Map = Dlg.SimpleFormDialog("E-Mail", "Create E-Mail", fieldlist)
   If resultMap.IsInitialized Then
     smtpEMail.Initialize("Server", 25, "Username", "Password", "smtp")
     smtpEMail.UseSSL = False
     Dim receipients() As String = Regex.Split(";", resultMap.Get("receipients"))
     smtpEMail.To.AddAll(receipients)
     smtpEMail.Subject = resultMap.Get("subject")
     smtpEMail.Body = resultMap.Get("body")
     smtpEMail.Send
     Wait For smtp_MessageSent(Success As Boolean)
     If Success Then
       Log($"Message has been successfully sent to ${resultMap.Get("receipients")}."$)
     Else
       Log("Message has not been sent.")
     End If
   End If
End Sub

Example: SQLite Database with CRUD operations
upload_2017-6-3_10-20-13.png

SFD is used to add or edit/update records.
The database has one table contacts: ID INTEGER PRIMARY KEY, Name TEXT, EMail TEXT, Notes TEXT
Code Snippet showing the Edit Database Record Dialog - Note that the DBUtils module is used.
B4X:
Sub EMailForm(ID As Int)
   ' Define the form field values with default values --- without the ID fields (as automatically updated)
   Dim idvalue As String = ""   'ignore
   Dim namevalue As String = "new name"
   Dim emailvalue As String = "new email"
   Dim notesvalue As String = "new content"
   ' Set the OK button text
   If ID = -1 Then
     Dlg.OKButtonText = "Add"
   Else
     Dlg.OKButtonText = "Update"
   End If
   ' Create the list of fieldmaps
   Dim fieldlist As List
   fieldlist.Initialize
   ' Get the record values if ID <> -1 and assign to the values
   Dim fieldMap As Map = DBUtils.ExecuteMap(sqlObj, $"SELECT * FROM ${TableContacts} where ID=?"$, Array As String(ID))
   If fieldMap.IsInitialized Then
     idvalue = fieldMap.Get("id")
     namevalue = fieldMap.Get("name")
     emailvalue = fieldMap.Get("email")
     notesvalue = fieldMap.Get("notes")
   End If
   ' Create the field list with new or updated values
   fieldlist.Add(CreateMap("id":"name", "label":"Name","value":$"${namevalue}"$, "type":"T"))
   fieldlist.Add(CreateMap("id":"email", "label":"E-Mail","value":$"${emailvalue}"$, "type":"T"))
   fieldlist.Add(CreateMap("id":"notes", "label":"Notes","value":$"${notesvalue}"$, "type":"A"))
   '   fieldlist.Add(CreateMap("id":"id", "label":"ID","value":$"${idvalue}"$, "type":"T"))
   'Open the dialog
   Dlg.SimpleFormSplitFields = cbSimpleFormSplitFields.Checked
   Dim resultMap As Map = Dlg.SimpleFormDialog("Contact Form", "Details", fieldlist)
   If resultMap.IsInitialized Then
     If ID = -1 Then
       Dim l As List
       l.Initialize
       l.Add(resultMap)
       Dim rt As String = DBUtils.InsertMaps(sqlObj, TableContacts, l)
       FillTableView
       LOg($"New record inserted. Result: ${rt}"$)
     Else
       Dim wherefieldequals As Map = CreateMap("ID":ID)
       Dim rt As String = DBUtils.UpdateRecord2(sqlObj, TableContacts, resultMap, wherefieldequals)
       FillTableView
       Log($"Record (ID:${ID} updated. Result: ${rt}"$)
     End If
   End If
End Sub

Sub FillTableView
   tvContacts.Items.Clear
   DBUtils.ExecuteTableView(sqlObj, $"SELECT * FROM ${TableContacts}"$, Null, 0, tvContacts)
End Sub
 
Last edited:

m4.s

Member
Licensed User
Longtime User
Hello Rob,

Thank you very much for the TextInputDialog4 enhancement -- it works just as requested!

I also really like your subsequent additions. Re: the SFD one, are you considering new support for a 'FilePicker' fieldtype? In the case of your email example, it would be preferable to allow a user to optionally attach one or more files as part of a sent email.
 

rwblinn

Well-Known Member
Licensed User
Longtime User
Thanks for feedback - appreciated.

Regarding FilePicker fieldtype need to consider if possible - in the meantime, a workaround could be:
Step 1
In the SFD E-Mail, add a new TextField field, i.e.
B4X:
fieldlist.Add(CreateMap("id":"attachment", "label":"Attachment:", "value":$"${attachment}"$, "type":"T"))
Step 2
Open the standard FileChooser Dialog (f.e. via Button Action) to select a file. Assign the dialog result to a String, i.e. attachment.
When the FileChooser Dialog is closed, open the SFD E-Mail.
B4X:
Sub btnSendEMailWithAttachment_Action
   Dim fc As FileChooser
   fc.Initialize
   fc.Title = "Select E-Mail Attachment"
   fc.InitialDirectory = File.DirApp
   Dim attachment As String = fc.ShowOpen(MainForm)
   ...SFD E-Mail Dialog with additional field...
 

rwblinn

Well-Known Member
Licensed User
Longtime User
Update 20170612 - Full Documentation here.
NEW: SliderDialog
NEW: SimpleFormDialog CheckBox Field
NEW: Extended Dialog option show content expanded
NEW: DoNotAskAgainDialog
UPD: Fields padding removed
UPD: Examples.

Screenshots
upload_2017-6-12_11-41-28.png

upload_2017-6-12_11-40-1.png
 

Art

Member
Licensed User
Longtime User
Not (yet) possible. Work in progress to include in the next version which will use B4J v5.50.
Meanwhile, you have done great improvements in your library and my string localisation request was generously fulfilled (thank you again!). However, in 'Message HTML', the 'Show/Hide Details' text link is hardcoded. Can it be excluded ou translated? Thank you, Rob!
 

rwblinn

Well-Known Member
Licensed User
Longtime User
Update 20170620 - Full Documentation here.
NEW: Localization Show Details Hyperlink Button for Dialogs Extended, Message, MessageHTML
NEW: Extended Dialog option Message & MessageHTML Dialogs
UPD: Examples

Example MessageHTMLDialog Localize OK & Show Details Hyperlink Button
B4X:
'Localize
Dlg.OKButtonText = "Close"
Dlg.MessageHTMLDialogShowLessDetailsText = "Show Less..."
Dlg.MessageHTMLDialogShowMoreDetailsText = "Show More..."

'Open HTML message dialog by loading the content from file.
Dlg.MessageHTMLDialogDialogExpanded = True
Dim msg As String = File.ReadString(File.DirApp, "messagehtmldialog.htm")
Dlg.MessageHTMLDialog("jRLDialogs8 Libary MessageHTMLDialog example", msg)
upload_2017-6-20_9-17-32.png
 

rwblinn

Well-Known Member
Licensed User
Longtime User
Update 20170626 - Full Documentation here.
NEW: MessageDialog set wrap
NEW: SimpleFormDialog set inputfield width
NEW: MessageHTMLDialog2
NEW: Overview file created with my B4XLibViewer
UPD: Examples

B4XLibViewer
Reworked my B4XLibViewer ( originally created back 2014 in the B4J early days whilst learning B4J - amaizing how B4J has evolved since = great ) using the latest version of B4J and jRLDialogs8.
Example jRLDialogs8 usage; manage settings: SimpleFormDialog, view library reference details, help: MessageHTMLDialog2, find name: TextInput.
The library reference can be exported to HTML or copied to the clipboard.
Note: parsing XML is not the easiest task - so there might be some hickups in the output.
upload_2017-6-26_11-46-51.png


Example Export HTML Library Overview
upload_2017-6-26_11-50-24.png
 

micro

Well-Known Member
Licensed User
Longtime User
Hi to all and many thanks for your library rwblinn.
Can you extend or how can I have a return of the buttons pressed in a MessageHtmlDialog?
Another small request:
The Toastmessage pane can have round edges?

Best regards
 

rwblinn

Well-Known Member
Licensed User
Longtime User
Can you extend or how can I have a return of the buttons pressed in a MessageHtmlDialog?
Will add a new dialog or an option to add both OK and Cancel Button returning True and False.

Hi to all and many thanks for your library rwblinn.
Another small request: The Toastmessage pane can have round edges?
Not so easy as thought after exploring several ways. Will put on the ToDo list but can not promise if possible :(.

Thanks a lot for using this library.
 

rwblinn

Well-Known Member
Licensed User
Longtime User
Update 20170703 - Full Documentation here.
NEW: ToastMessageAlert Information,Warning,Error.
NEW: MessageHTMLDialog3 with OK/Cancel buttons.
NEW: MessageHTMLDialog property to show/hide details button.
UPD: Examples.

Example ToastMessageAlert Information, Warning, Error
B4X:
Private Const Duration as Int = 5000 'in ms

Sub btnToastMessageAlertInformation_Action
    'Style the border color, border width, border radius and font size.
    Dlg.ToastMessageAlertStyle(CSSUtils.ColorToHex(fx.Colors.LightGray), 2,2,16)
    Dlg.ToastMessageAlert("information", "ToastMessageAlert Information", "Thank You for using jRLDialogs8", Duration)
End Sub

Sub btnToastMessageAlertWarning_Action
    Dlg.ToastMessageAlertStyle(CSSUtils.ColorToHex(fx.Colors.Yellow), 4,2,20)
    Dlg.ToastMessageAlert("warning", "ToastMessageAlert Warning", "Thank You for using jRLDialogs8", Duration)
End Sub

Sub btnToastMessageAlertError_Action
    Dlg.ToastMessageAlertStyle(CSSUtils.ColorToHex(fx.Colors.Red), 6,2,24)
    Dlg.ToastMessageAlert("error", "ToastMessageAlert Error", "Thank You for using jRLDialogs8", Duration)
End Sub
upload_2017-7-3_16-31-20.png
 

LWGShane

Well-Known Member
Licensed User
Longtime User
@rwblinn - Is it possible to add a ComboBox to the SimpleFormDialog?
 

rwblinn

Well-Known Member
Licensed User
Longtime User
Update 20170711 - Full Documentation here.
NEW: SimpleFormDialog ComboBox Field with field value comma separated string, i.e. "Item 1,Item 2,Item 3".
NEW: SimpleFormDialog Property ComboBox editable.
UPD: Examples.

Example SimpleFormDialog with editable ComboBox

B4X:
'Create the list of fieldmaps
Dim fieldlist As List
fieldlist.Initialize
fieldlist.Add(CreateMap("id":"textfield", "label":"Textfield", "value":"textfield", "type":"T"))
fieldlist.Add(CreateMap("id":"numeric", "label":"Numeric", "value":"1958", "type":"N"))
fieldlist.Add(CreateMap("id":"password", "label":"Password", "value":"password", "type":"P"))
fieldlist.Add(CreateMap("id":"checkbox", "label":"Checkbox", "value":"1", "type":"C"))
fieldlist.Add(CreateMap("id":"combobox", "label":"Combobox", "value":"Item 1,Item 2,Item 3", "type":"B"))
'Open the dialog
Dlg.SimpleFormSplitFields = True
Dlg.SimpleFormComboBoxEditable = True
Dim resultmap As Map = Dlg.SimpleFormDialog("SimpleFormDialog", "Header", fieldlist)
'The resultmap holds for each field the pair id:value
If resultmap.IsInitialized Then
      Dim sb As StringBuilder
      sb.Initialize
      For i = 0 To resultmap.Size - 1
          sb.Append($"${resultmap.GetKeyAt(i)} = ${resultmap.GetValueAt(i)}"$).Append(CRLF)
      Next
      Log(sb.tostring)
Else
      Log("User Abort")
End If
upload_2017-7-12_7-58-8.png
 
Top