These four images are real screenshots from the supplied example projects. They are not mockups. The first two modes share DESIGN_CLASSIC_LOGO, but demonstrate two distinct compositions of the same API.
Real use of DESIGN_CLASSIC_LOGO combined with SetHeader and SetBottomPanel. The title/subtitle stay fixed and the bottom area is used for New License.
The same base style 1 is used as a classic menu: large logo/image, title and options with icons on the left.
DESIGN_MODERN_INDICATOR uses more compact rows and a 7 px side bar for hover and selection.
DESIGN_COMPACT_ICON reduces the menu to 140 px and places the icon above the text, leaving more room for content.
Menus & Navigation · jdashboardUI · B4J
JWindowsMenuStyle builds the side navigation used together with jdashboard_WindowsStyle. It manages reserved menu width, menu items, selection, images or icon fonts, header content, a custom bottom panel, and automatic layout updates when the window is resized or maximize / restore animations finish.
This page is based on the real JWindowsMenuStyle.bas source and the supplied example projects, including JLicenseGenerator, Antivirus style, Store Example, and ejemplo ui 2.
Main capabilities
- Integrates directly with
jdashboard_WindowsStyle. - Automatically changes the window
MenuTypefor the selected style. - 3 implemented base visual styles with 4 real-world usage modes demonstrated by the supplied projects.
- Image-based or font-icon menu items.
EventName_OptionClickedevents.- Hover and selected states.
- Programmatic item selection.
- Static title/subtitle header.
- Custom bottom panel.
- Resize and maximize/restore layout handling.
- Global font and color customization.
Declaration and initialization
Private ui As jdashboard_WindowsStyle
Private menu As JWindowsMenuStyle
Initialize the window first, then the menu:
menu.Initialize(ui)
menu.StyleMenu = menu.DESIGN_CLASSIC_LOGO
menu.InitializePanels(Me, MainForm, fx.Colors.RGB(96, 118, 146))
Set StyleMenu before InitializePanels, because the style controls the menu width and internal layout.
3 base styles and 4 real-world usage modes
After reviewing the complete JWindowsMenuStyle.bas implementation and the supplied projects, the most accurate description is:
- 3 base visual styles are fully implemented by the layout and item-rendering logic.
- 4 real-world usage modes are visible in the example projects because the classic style supports two clearly different compositions.
DESIGN_MODERN_MENU = 4is declared by the API, but in this version it does not provide a fourth independent item renderer.setStyleMenu(4)mapsjdashboard_WindowsStyleback toMenu_type_1, whileInitializePanels,Add_MenuItem,Add_MenuItem2, hover/selection and item-height logic contain dedicated cases for styles 1, 2 and 3.
Base visual styles
| Constant | Value | Current implementation | Structure |
|---|---|---|---|
DESIGN_CLASSIC_LOGO |
1 | Complete | Wide menu, icon at the left, upper identity area. |
DESIGN_COMPACT_ICON |
2 | Complete | 140 px menu, icon above centered text. |
DESIGN_MODERN_INDICATOR |
3 | Complete | Wide menu, 46 px rows and 7 px side indicator. |
DESIGN_MODERN_MENU |
4 | Compatibility / reserved in this version | Maps to Menu_type_1; no separate item layout. |
The 4 modes shown by the real examples
Mode 1A — Classic + Header + Bottom Panel
Project: License Generator.
This uses base style 1 together with:
menu.SetHeader("License Pro", "Enterprise Control")
menu.SetBottomPanel(CreateLicenseMenuPanel)
It produces an administration layout with a fixed title/subtitle and a dedicated bottom action area.
Mode 1B — Classic Logo / dynamic identity
Reference project: Postman B4X / classic example.
This is the direct DESIGN_CLASSIC_LOGO composition: wide sidebar, left-side icons and an upper area for a logo, image or title.
Mode 2 — Compact Icon
Project: B4X Antivirus Pro.
menu.StyleMenu = menu.DESIGN_COMPACT_ICON
- base width: 140 px;
- item height: 100 px;
- icon above the label;
- centered text;
- more room left for the main content.
Mode 3 — Modern Indicator
Project: DataFlow / Store Example.
menu.StyleMenu = menu.DESIGN_MODERN_INDICATOR
- base width: 261 px;
- item height: 46 px;
- icon on the left;
- 7 px hover/selection indicator;
- higher vertical density for dashboards.
Real screenshots
The gallery at the top of this documentation uses the four original screenshots supplied for License Generator, Postman B4X, DataFlow and B4X Antivirus Pro. No mockups are used inside the topic.
Add an image item
menu.Add_MenuItem( _
"Dashboard", _
xui.Color_RGB(77, 166, 255), _
"Dashboard", _
fx.Colors.White, _
File.DirAssets, _
"dashboard.png", _
"Open dashboard", _
True)
Add a font-icon item
menu.Add_MenuItem2( _
"Home", _
xui.Color_Transparent, _
"Home", _
fx.Colors.White, _
Chr(0xF0E4), _
fx.CreateFontAwesome(30), _
fx.Colors.RGB(0, 105, 155), _
"Home", _
True)
Simple helpers
menu.MenuTextColor = fx.Colors.White
menu.Add_MenuItem2Simple( _
"Dashboard", _
"Generator", _
Chr(0xE871), _
xui.CreateMaterialIcons(18), _
fx.Colors.White, _
True)
Add_MenuItemSimple and Add_MenuItem2Simple reuse the global MenuTextColor and omit the tooltip.
Events
An item with EventName = "Dashboard" raises:
Private Sub Dashboard_OptionClicked
Log("Dashboard")
End Sub
Events are dispatched through CallSubDelayed.
Programmatic selection
menu.SelectMenuItem("Dashboard")
This updates selection state, style-3 indicator, title/logo data when available, and raises the corresponding _OptionClicked event.
To clear only the visual selection:
menu.ClearSelection
ClearSelection does not raise an event.
Static header
Styles 1 and 3 can use a static title/subtitle header:
menu.SetHeader("License Pro", "Enterprise Control")
menu.title_color(fx.Colors.RGB(128, 131, 255))
menu.TitleTextSize = 20
menu.SubtitleFont = xui.CreateDefaultBoldFont(11)
menu.SubtitleTextSize = 11
When a static header is enabled, item selection no longer replaces the main title via SetTitle.
Custom bottom panel
menu.SetBottomPanel(CreateLicenseMenuPanel)
The class measures the panel contents, places it at the bottom, and recalculates the remaining list area.
Typical uses include user profiles, special actions, session information, or a New License button.
Logo and title
menu.setlogo(File.DirAssets, "home@512px.png")
menu.setLogo2( _
Chr(0xF0E4), _
fx.CreateFontAwesome(80), _
fx.Colors.White)
menu.SetTitle("Dashboard")
Style 2 intentionally ignores the logo methods.
Fonts and text
menu.SetAllFonts(xui.CreateDefaultBoldFont(14))
menu.TitleFont = xui.CreateDefaultBoldFont(22)
menu.TitleTextSize = 22
menu.SubtitleFont = xui.CreateDefaultFont(11)
menu.SubtitleTextSize = 11
menu.MenuTextColor = fx.Colors.LightGray
Direct label access:
Dim Title As Label = menu.TitleLabel
Dim Subtitle As Label = menu.SubtitleLabel
Resize behavior
The class listens to the JavaFX stage width and height properties and registers itself through:
mWinStyle.RegisterOnMaximizeComplete(Me)
When maximize/restore animation finishes, OnMaximizeComplete recalculates the menu and repositions the bottom panel.
Manual refresh:
menu.ResetLayout
When a bottom panel exists, the available list height is rounded to a complete number of menu rows so the last item is not cut.
Actual dimensions
| Style | Base width | Item height |
|---|---|---|
| Classic Logo | 261 px | 65 px |
| Compact Icon | 140 px | 100 px |
| Modern Indicator | 261 px | 46 px |
Public API
| Member | Purpose |
|---|---|
Initialize(WinStyle) |
Connects the menu to jdashboard_WindowsStyle. |
StyleMenu |
Selects a menu design. |
InitializePanels(callback, frm, color_selected) |
Builds the menu and configures selection/resize. |
MenuClear |
Removes all menu items. |
ResetLayout |
Forces a layout recalculation. |
OnMaximizeComplete |
Maximize/restore completion callback. |
title_color |
Changes title color. |
subtitle_color |
Changes subtitle color. |
SetTitle |
Changes dynamic title. |
setlogo |
Uses an image as the menu logo. |
setLogo2 |
Uses a font icon as the menu logo. |
SetAllFonts |
Updates title and item fonts. |
Add_MenuItem |
Adds an image item. |
Add_MenuItem2 |
Adds a font-icon item. |
Add_MenuItemSimple |
Simplified image item. |
Add_MenuItem2Simple |
Simplified font-icon item. |
SetHeader |
Enables a static title/subtitle header. |
SetBottomPanel |
Adds a custom bottom panel. |
TitleLabel |
Returns the title Label. |
SubtitleLabel |
Returns the subtitle Label. |
MenuTextColor |
Global text color used by simple helpers. |
TitleFont / TitleTextSize |
Main title font and size. |
SubtitleFont / SubtitleTextSize |
Subtitle font and size. |
SelectMenuItem |
Selects an item and raises its event. |
ClearSelection |
Clears selection without raising events. |
colortobackcolor |
Returns a slightly darker color. |
No-menu windows
No_menu belongs to jdashboard_WindowsStyle, not JWindowsMenuStyle.
ui.MenuType = ui.No_menu
If you do not need a side menu, you do not need to build JWindowsMenuStyle.
Important source-backed notes
- The analyzed class targets B4J.
- Set
StyleMenubeforeInitializePanels. - Item-building logic currently implements styles 1, 2 and 3.
- Style 2 does not use the top logo.
SetHeaderis intended for styles 1 and 3.- The menu is internally backed by
CustomListView. - Bottom-panel layout avoids clipped last rows.
- Event naming follows
EventName_OptionClicked. SelectMenuItemraises the event;ClearSelectiondoes not.
Related
- jdashboard_WindowsStyle — window shell and side-menu reservation.
- jdashboardUtils — UI utilities used by this class.
- JMenuBar — a separate top-menu system.