Hi everyone! I’m excited to share a preview of one of the most powerful features arriving in the upcoming update of JDashboardUI: the all-new JMenuBar.
I have completely reimagined how we handle menus in B4J to ensure they are as fluid, modern, and professional as the rest of the suite.
JMenuBar
Author: Fernado Arevalo
Version: 1.0
Methods:
Initialize (Callback As Object, EventName As String)
Initializes the JMenuBar control.
Callback is the object that will receive the events.
EventName is the event prefix.
AddMenu (MenuName As String, Text As String)
Adds a main menu to the menu bar.
MenuName is the internal identifier.
Text is the visible text of the menu.
AddMenu2 (MenuName As String, Text As String, IconChar As String, IconFont As B4XFont, IconColor As Int)
Adds a main menu with an icon.
IconChar is the icon character.
IconFont is the font used for the icon.
IconColor is the color of the icon.
AddSubMenu (ParentMenuName As String, SubMenuName As String, Text As String, IconChar As String, IconFont As B4XFont, IconColor As Int)
Adds a submenu to an existing menu.
ParentMenuName is the name of the parent menu.
SubMenuName is the identifier of the submenu.
AddMenuItem (MenuName As String, EventName As String, IconText As String, FontIcon As B4XFont, ColorIcon As Int, MainText As String, Tooltip As String)
Adds a clickable item inside a menu.
MenuName is the target menu.
EventName is the event triggered when the item is clicked.
IconText is the icon character.
MainText is the displayed text.
AddSeparator (MenuName As String, Color As Int)
Adds a separator line inside a menu.
MenuName is the menu where the separator will be added.
Color is the color of the separator line.
IsInitialized As Boolean
Tests whether the object has been initialized.
This is the part you’ll love the most. Traditionally, a MenuBar requires one massive event with a long Select Case to figure out which item was clicked. In the new JDashboardUI, every item speaks for itself.
Simply write this in your code:
No intermediaries, no extra boilerplate—just clean, readable code.
Here is how the hierarchy works. Notice how SubMenus are populated by using their own ID as the parent:
As always, it features full support for Dark Themes, MaterialIcons, FontAwesome, etc, and custom colors for every single icon to match your brand's identity.
While the library is still being polished for the final release, I want you to experience the feel and performance of the new JMenuBar today.
I’ve prepared a compiled demo (EXE) so you can test the hierarchy, the hover effects, and the smooth interface yourself.
[Download Compiled Demo Here]
Stay tuned! The update is closer than ever.
I have completely reimagined how we handle menus in B4J to ensure they are as fluid, modern, and professional as the rest of the suite.
JMenuBar
Author: Fernado Arevalo
Version: 1.0
Methods:
Initialize (Callback As Object, EventName As String)
Initializes the JMenuBar control.
Callback is the object that will receive the events.
EventName is the event prefix.
AddMenu (MenuName As String, Text As String)
Adds a main menu to the menu bar.
MenuName is the internal identifier.
Text is the visible text of the menu.
AddMenu2 (MenuName As String, Text As String, IconChar As String, IconFont As B4XFont, IconColor As Int)
Adds a main menu with an icon.
IconChar is the icon character.
IconFont is the font used for the icon.
IconColor is the color of the icon.
AddSubMenu (ParentMenuName As String, SubMenuName As String, Text As String, IconChar As String, IconFont As B4XFont, IconColor As Int)
Adds a submenu to an existing menu.
ParentMenuName is the name of the parent menu.
SubMenuName is the identifier of the submenu.
AddMenuItem (MenuName As String, EventName As String, IconText As String, FontIcon As B4XFont, ColorIcon As Int, MainText As String, Tooltip As String)
Adds a clickable item inside a menu.
MenuName is the target menu.
EventName is the event triggered when the item is clicked.
IconText is the icon character.
MainText is the displayed text.
AddSeparator (MenuName As String, Color As Int)
Adds a separator line inside a menu.
MenuName is the menu where the separator will be added.
Color is the color of the separator line.
IsInitialized As Boolean
Tests whether the object has been initialized.
Intuitive Hierarchy
Forget about tangled configurations. JMenuBar uses a clean "Parent-Child" structure that is extremely easy to follow:- Main Menu: The root entry point (e.g., "File").
- SubMenu: An item that expands to show more options (e.g., "Export as...").
- MenuItem: The final action item, featuring icons, descriptions, and shortcuts.
Direct Events: Goodbye "Select Case"
This is the part you’ll love the most. Traditionally, a MenuBar requires one massive event with a long Select Case to figure out which item was clicked. In the new JDashboardUI, every item speaks for itself.Quick Example: If you define an item with the ID "expPDF": JMenuBar1.AddMenuItem("subExport", "expPDF", ...)The Event Magic: To create a click action, you only need to create a Sub using the item's ID + the suffix _MenuItemClicked.
Simply write this in your code:
Click:
Sub expPDF_MenuItemClicked
Log("Exporting to PDF...")
End Sub
No intermediaries, no extra boilerplate—just clean, readable code.
Preview: Implementation & SubMenus
Here is how the hierarchy works. Notice how SubMenus are populated by using their own ID as the parent:
JMenuBar:
Sub CreateMenu
' 1. Create Main Menu "File"
JMenuBar1.AddMenu("mnuFile", "File")
JMenuBar1.AddMenuItem("mnuFile", "new", Chr(0xE226), xui.CreateMaterialIcons(20), xui.Color_White, "Create new project", "Ctrl+N")
JMenuBar1.AddMenuItem("mnuFile", "open", Chr(0xE2CC), xui.CreateMaterialIcons(20), xui.Color_White, "Open existing project", "Ctrl+O")
JMenuBar1.AddSeparator("mnuFile", xui.Color_DarkGray)
' 2. Create SUBMENU "Export" inside "File"
JMenuBar1.AddSubMenu("mnuFile", "subExport", "Export as...", Chr(0xf46d), icon.IconFontAwesomeSolid, xui.Color_RGB(153, 103, 235))
' Fill the Submenu using its ID "subExport"
JMenuBar1.AddMenuItem("subExport", "expPDF", Chr(0xf1c1), icon.IconFontAwesomeSolid, xui.Color_RGB(250, 188, 192), "Export to PDF", "")
JMenuBar1.AddMenuItem("subExport", "expExcel", Chr(0xf1c3), icon.IconFontAwesomeSolid, xui.Color_RGB(122, 168, 120), "Export to Excel", "")
JMenuBar1.AddMenuItem("subExport", "expImage", Chr(0xf03e), icon.IconFontAwesomeSolid, xui.Color_RGB(195, 238, 243), "Export to Image", "")
JMenuBar1.AddSeparator("mnuFile", xui.Color_DarkGray)
JMenuBar1.AddMenuItem("mnuFile", "exit", Chr(0xE5CD), xui.CreateMaterialIcons(20), xui.Color_White, "Exit application", "Alt+F4")
' 3. Create Main Menu "Edit"
JMenuBar1.AddMenu2("mnuEdit", "Edit", Chr(0xf0ad), icon.IconFontAwesomeSolid, xui.Color_RGB(235, 208, 103))
JMenuBar1.AddMenuItem("mnuEdit", "undo", Chr(0xE166), xui.CreateMaterialIcons(20), xui.Color_White, "Undo last action", "Ctrl+Z")
JMenuBar1.AddMenuItem("mnuEdit", "redo", Chr(0xE15A), xui.CreateMaterialIcons(20), xui.Color_White, "Redo last action", "Ctrl+Y")
JMenuBar1.AddSeparator("mnuEdit", xui.Color_LightGray)
JMenuBar1.AddMenuItem("mnuEdit", "copy", Chr(0xE14D), xui.CreateMaterialIcons(20), xui.Color_White, "Copy to clipboard", "Ctrl+C")
JMenuBar1.AddMenuItem("mnuEdit", "paste", Chr(0xE14F), xui.CreateMaterialIcons(20), xui.Color_White, "Paste from clipboard", "Ctrl+V")
' 4. Create Main Menu "Help"
JMenuBar1.AddMenu("mnuHelp", "Help")
JMenuBar1.AddMenuItem("mnuHelp", "about", Chr(0xf05a), icon.IconFontAwesomeSolid, xui.Color_RGB(95, 154, 213), "Version information", "")
End Sub
' ==========================================
' FILE MENU EVENTS
' ==========================================
Sub new_MenuItemClicked
Log("Menu Clicked: New Project")
End Sub
Sub open_MenuItemClicked
Log("Menu Clicked: Open Project")
End Sub
Sub exit_MenuItemClicked
Log("Menu Clicked: Exit Application")
' ExitApplication ' Descomenta para cerrar la app
End Sub
' ==========================================
' EXPORT SUBMENU EVENTS
' ==========================================
Sub expPDF_MenuItemClicked
Log("Menu Clicked: Export to PDF")
End Sub
Sub expExcel_MenuItemClicked
Log("Menu Clicked: Export to Excel")
End Sub
Sub expImage_MenuItemClicked
Log("Menu Clicked: Export to Image")
End Sub
' ==========================================
' EDIT MENU EVENTS
' ==========================================
Sub undo_MenuItemClicked
Log("Menu Clicked: Undo")
End Sub
Sub redo_MenuItemClicked
Log("Menu Clicked: Redo")
End Sub
Sub copy_MenuItemClicked
Log("Menu Clicked: Copy")
End Sub
Sub paste_MenuItemClicked
Log("Menu Clicked: Paste")
End Sub
' ==========================================
' HELP MENU EVENTS
' ==========================================
Sub about_MenuItemClicked
Log("Menu Clicked: About / Version Info")
End Sub
Premium UI/UX
As always, it features full support for Dark Themes, MaterialIcons, FontAwesome, etc, and custom colors for every single icon to match your brand's identity. Try the Demo!
While the library is still being polished for the final release, I want you to experience the feel and performance of the new JMenuBar today.I’ve prepared a compiled demo (EXE) so you can test the hierarchy, the hover effects, and the smooth interface yourself.
[Download Compiled Demo Here]
Stay tuned! The update is closer than ever.
Last edited: