JToolBar es una barra de herramientas de B4J que permite combinar botones, iconos, imágenes, controles propios, campos de texto, ComboBox, menús desplegables y submenús. Con Wrap = True, sus elementos se reorganizan en varias filas. Puedes utilizarla en editores de documentos, dashboards, exploradores de archivos y aplicaciones con acciones rápidas.
Primeros pasos
- Activa jdashboardUI en B4J y coloca un CustomView
JToolBarllamadoToolBar1desde el Designer. - Carga el layout antes de llamar a
AddButton,AddMenuButtono cualquier otro método de inserción. - Configura
RowHeight,Wrap, espacios, colores y bordes. Reserva altura suficiente en el panel padre. - Crea un evento
EventName_Clickpor cada acción que necesites ejecutar.
MainForm.RootPane.LoadLayout("Main")
ToolBar1.Wrap = True
ToolBar1.RowHeight = 36dip
ToolBar1.AddButton("guardar", "Guardar")
ToolBar1.AddButton("deshacer", "Deshacer")
ToolBar1.AddSeparator
ToolBar1.AddMenuButton("exportar", Chr(0xF0C7), xui.CreateFontAwesome(16), 0xFF334155, "Exportar")
ToolBar1.AddMenuItem("exportar", "guardarPDF", "Guardar como PDF")
ToolBar1.AddSubMenu("exportar", "formatos", "Otros formatos")
ToolBar1.AddMenuItem("formatos", "guardarTXT", "Archivo TXT")
Private Sub guardar_Click
Log("Guardar documento")
End Sub
Private Sub guardarPDF_Click
Log("Guardar como PDF")
End Sub
La primera cadena en AddMenuItem identifica al botón o submenú padre; la segunda es el nombre que determina el evento. Para mostrar un ComboBox o TextField dentro de un menú, utiliza AddMenuView(ParentEventName, EventName, View, Width, Height, HideOnClick). Si HideOnClick = False, el menú puede permanecer abierto durante la interacción con la vista.
¿Qué puedo construir?
- Editor: Guardar, Deshacer, Rehacer, selector de fuente y menú Exportar.
- Dashboard: botones de refresco y filtros dentro de un menú.
- Explorador: controles de navegación y una barra de ruta.
- Formulario: acciones de guardar, validar y copiar con diferentes estados.
El conjunto de 84 Public Sub cubre botones, separadores, vistas, submenús, estados Enabled/Visible, seleccionados, color, estilo, eventos y reordenamiento. A continuación se conserva la referencia técnica completa, con firmas B4J exactas, parámetros, retornos y ejemplos extensos (incluyendo el texto de referencia en inglés para mantener sin cambios los identificadores de código).
Referencia técnica completa, firmas de API y casos avanzados
Library: jdashboardUI · Platform: B4J / JavaFX · Verified against:
jdashboardUI(20261108-154221).b4xlib(8 November 2026). This is a user-facing tutorial, not documentation for library internals.
JToolBar builds a responsive command bar for a desktop application. You can combine traditional buttons, glyph buttons, image buttons, text fields, combo boxes, your own B4J controls, dropdown menus, nested menus and controls embedded inside a menu. When Wrap=True, controls move to additional rows as the available width decreases. Menus are native JavaFX ContextMenu objects created and maintained by the library; you do not create or position their popups yourself.
1. When to use JToolBar
Use JToolBar for an editor's Save / Undo / Redo controls; a browser-like address bar; a formatting bar with font selection; a navigation header with breadcrumbs; image-tool commands; application dashboards with quick filters; or a compact File/Export dropdown. Prefer a JToolBar dropdown when a few closely related commands belong to one icon; prefer JMenuBar for the main top-level File / Edit / Help menu; prefer JTreeList for a hierarchical project explorer.
2. Project prerequisites
- Open a B4J project in B4J 10.70 (the library sources target B4J 10.7).
- Install the current jdashboardUI
.b4xlibin the B4J additional libraries folder and select it in the Libraries Manager. Add any standard libraries your project uses, notablyXUI,JavaObjectand the applicable B4X views. - Add a
JToolBarCustomView in the Visual Designer, name itToolBar1, and load that layout before calling anyToolBar1.Add...method. Alternatively, create the view in B4J code withInitializefollowed byAddToParent. - Keep enough vertical space for additional rows.
Wrap=Truechanges the layout of toolbar items; it does not automatically enlarge the parent container. - Create event handlers on the same callback object supplied to
Initializeor implicitly associated with the Designer view.
2.1. Code-created toolbar (complete starting example)
Sub Process_Globals
Private fx As JFX
Private xui As XUI
Private MainForm As Form
Private Commands As JToolBar
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.Show
BuildCommands
End Sub
Private Sub BuildCommands
Commands.Initialize(Me, "Commands")
Commands.AddToParent(MainForm.RootPane, 12dip, 12dip, 720dip, 90dip)
Commands.Wrap = True
Commands.RowHeight = 32dip
Commands.Spacing = 3dip
Commands.RowSpacing = 2dip
Commands.BackgroundColor = 0x00FFFFFF
Commands.AddButton("newDoc", "New")
Commands.AddButton("saveDoc", "Save")
Commands.AddSeparator
Commands.AddIconButton("refresh", Chr(0xF021), xui.CreateFontAwesome(16), 0xFF444444, "Refresh")
End Sub
Private Sub newDoc_Click
Log("Create a new document")
End Sub
Private Sub saveDoc_Click
Log("Save the current document")
End Sub
Private Sub refresh_Click
Log("Refresh requested")
End Sub
Result: three clickable actions appear; the separator divides Save and Refresh; when the host is narrower, controls can move to a second row. If your application already has a MainForm, adapt only the parent variable.
2.2. Designer-created toolbar
In the B4J Visual Designer, add a JToolBar CustomView named ToolBar1. Load the layout in AppStart and then populate the toolbar:
MainForm.RootPane.LoadLayout("Main")
ToolBar1.AddButton("save", "Save")
ToolBar1.AddButton("print", "Print")
Private Sub save_Click
Log("Save")
End Sub
Do not separately call Initialize on a Designer-created view already initialized by layout loading. Remember that the names save_Click and print_Click come from each button's EventName, not the name of the toolbar.
3. Buttons, icons, images and tooltips
3.1. Text button
Commands.AddButton("save", "Save", Chr(0xF0C7), xui.CreateFontAwesome(16), _
0xFF2764B4, "Save this document", True, True)
The first argument is the stable event identifier. The second is displayed text. Icon is optional; when using a glyph, pass its corresponding IconFont. IconColor controls the glyph and ToolTipText is displayed on hover. The final two flags control initial enabled and visible states. AddButton returns the native JavaFX Button if you need direct access to it.
3.2. Icon-only and image-only buttons
Commands.AddIconButton("undo", Chr(0xF0E2), xui.CreateFontAwesome(16), _
0xFF3C4858, "Undo last change")
Commands.AddImageButton("logo", File.DirAssets, "brand.png", "About this application")
Put brand.png in the B4J Files tab. AddImageButton loads it using the supplied directory and filename; missing images can cause loading failures. Icons and images occupy a compact hit area while retaining tooltip support. Use glyphs for consistent monochrome commands and images for distinctive product artwork.
3.3. Exclusive actions versus toggle buttons
Ordinary buttons are momentary actions. A formatting command such as Bold may need a persistent selected state:
Commands.AddButton("bold", "Bold")
Commands.SetButtonToggleOnClick("bold", True)
Private Sub bold_Click
Log("Bold active: " & Commands.GetButtonSelected("bold"))
End Sub
Sub ReflectSelectionFromEditor (IsBold As Boolean)
Commands.SetButtonSelected("bold", IsBold)
End Sub
SetButtonToggleOnClick makes clicks alternate selected/unselected. SetButtonSelected is useful when another component—such as a text editor—changes the state without clicking the toolbar. This is not a mutually exclusive radio-button group; coordinate two toggle buttons yourself if your app requires exclusivity.
4. Text fields, ComboBoxes and custom controls
4.1. Editable address / search field
Private SearchField As TextField
SearchField = Commands.AddTextField("query", "", 260dip, True, "Search documents")
Private Sub Commands_TextFieldAction (EventName As String, Text As String)
If EventName = "query" Then Log("Search for: " & Text)
End Sub
TextFieldAction is the toolbar-level event, raised when Enter is pressed in an editable field added with AddTextField. Its EventName identifies which text field fired; its Text contains the current value. For a read-only breadcrumb, pass Editable=False; it remains enabled so the text can be selected or copied.
4.2. Place an existing ComboBox inside the toolbar
Private Fonts As ComboBox
Fonts.Initialize("Fonts")
Fonts.Items.AddAll(Array As String("Arial", "Calibri", "Consolas"))
Fonts.Value = "Consolas"
Commands.AddViewWithEventName2("fontSelector", Fonts, 150dip, 26dip)
Private Sub Fonts_SelectedIndexChanged(Index As Int, Value As Object)
Log("Selected font: " & Value)
End Sub
Important: AddView... moves the original JavaFX control under the toolbar; it does not clone it. Its original B4J event name (Fonts) remains in use. The JToolBar registration name (fontSelector) is for toolbar lookups, visibility and enabled-state operations. AddView and AddView2 accept native B4J views or jdashboardUI CustomViews exposing GetBase or public mBase.
AddViewWithId and AddViewWithId2 are still public compatibility aliases. Use WithEventName in new projects for consistency with the other toolbar methods.
4.3. Runtime control of the registered view
Commands.SetItemEnabled("fontSelector", False)
Commands.SetItemVisible("fontSelector", False)
Log(Commands.GetItemEnabled("fontSelector"))
Log(Commands.GetItemVisible("fontSelector"))
Commands.SetItemToolTip("fontSelector", "Choose a typeface")
Hidden views are excluded from the toolbar layout so the remaining items reflow. A disabled control remains visible but does not normally accept user input.
5. Dropdown menus built into JToolBar
5.1. Compact dropdown button
Commands.AddMenuButton("fileMenu", Chr(0xF0C7), xui.CreateFontAwesome(16), _
0xFF2857A5, "File commands")
Commands.AddMenuItem("fileMenu", "saveMenu", "Save")
Commands.AddMenuItem("fileMenu", "saveAsMenu", "Save As...")
Commands.AddMenuSeparator("fileMenu")
Commands.AddMenuItem("fileMenu", "closeMenu", "Close")
Private Sub saveMenu_Click
Log("Save from dropdown")
End Sub
fileMenu is the parent EventName. Each menu child has a unique EventName for its click handler. Unlike toolbar buttons, nested item events are named after the child identifier, not the parent. A menu is empty until you add at least one child.
Use AddMenuButton2 if the default compact dimensions are too small, for example if you want 48 × 34 dip. Use AddMenuImageButton to place a file image on the dropdown button rather than a font glyph.
5.2. Nested submenu
Commands.AddSubMenu("fileMenu", "exportMenu", "Export")
Commands.AddMenuItem("exportMenu", "exportJson", "JSON")
Commands.AddMenuItem("exportMenu", "exportTxt", "Plain text")
Private Sub exportJson_Click
Log("Export JSON")
End Sub
You can add descendants to the submenu by using its EventName as the next ParentEventName. Plan a unique identifier for every nested entry. A well-chosen pattern is file.export / file.export.json, although the B4J callback naming convention is easier with identifiers such as exportJson.
5.3. Images in menu entries
Commands.AddMenuImageItem("fileMenu", "exportPdf", "Export PDF", _
File.DirAssets, "pdf.png")
An image menu entry can be mixed freely with normal text/glyph menu entries. AddMenuItem and AddMenuImageItem return a native JavaObject for advanced JavaFX use; everyday B4J projects normally do not need to manipulate that native object.
5.4. Embed a form control in a menu
Private MenuSearch As TextField
MenuSearch.Initialize("MenuSearch")
MenuSearch.PromptText = "Find within project"
Commands.AddMenuView("fileMenu", "searchPanel", MenuSearch, 220dip, 26dip, False)
Private Sub MenuSearch_Action
Log("Search: " & MenuSearch.Text)
Commands.HideMenus
End Sub
This is useful for search boxes, font pickers, filters or small preference editors. HideOnClick=False is the default so interacting with the input does not immediately close the popup. If your embedded control acts like a one-shot selection, pass True. Its own JavaFX/B4J event handlers remain attached because the same view instance is moved inside the menu.
5.5. Open, close and replace dropdown contents
Commands.ShowMenu("fileMenu") ' Opens a nonempty, enabled root menu at its button.
Commands.HideMenus ' Closes currently visible toolbar dropdowns.
Commands.ClearMenu("fileMenu") ' Removes only the children of this root menu.
ShowMenu does nothing for a missing, disabled, invisible or empty root menu. ClearMenu is not the same as Clear: one removes a specific menu's contents; the other clears the toolbar items as a whole.
6. Element order, removal and dynamic visibility
Commands.MoveItem("fontSelector", 0) ' Zero-based index; separators count.
Commands.SetVisible("save", False) ' Alias for general visibility operations.
Commands.SetEnabled("undo", False) ' Alias for general enabled operations.
Commands.RemoveItem("undo") ' Remove one registered toolbar element.
Commands.Clear ' Remove all toolbar elements.
Only move/reorder toolbar entries using MoveItem; it does not reorder children within a native dropdown. GetItem("save") returns the registered native Button as an Object that may be cast to its actual type. If a lookup does not exist, handle Null rather than assuming a control was found.
7. Event routing: two important rules
- For a toolbar-created button or menu command, the library first looks for a callback named
<ElementEventName>_Click(for example,save_Click). - If that specific callback is not present, the general
<ToolbarName>_ItemClick(EventName As String)provides a convenient fallback. This means you should not assume both are called for the same click.
Private Sub Commands_ItemClick(EventName As String)
Select EventName
Case "undo": Log("Undo")
Case "refresh": Log("Refresh")
End Select
End Sub
Text fields use Commands_TextFieldAction(EventName, Text) instead. A custom ComboBox or other reparented view preserves its own events, such as Fonts_SelectedIndexChanged. Distinguish the toolbar callback prefix from each control's individual EventName.
8. Responsive layouts, rows and dimensions
Commands.Wrap = True
Commands.RowHeight = 32dip
Commands.RowSpacing = 3dip
Commands.Spacing = 4dip
Commands.SeparatorSpacing = 6dip
Commands.PaddingLeft = 6dip
Commands.PaddingRight = 6dip
Commands.PaddingTop = 2dip
Commands.PaddingBottom = 2dip
With wrapping enabled, items go to the next row when they would exceed the available width. Larger custom views may cause the occupied row to grow taller. The minimum RowHeight is 32dip and the button cell height is normally 26dip. The toolbar clips its content to the host bounds; increase host height or place it inside an adequately sized layout. A separator at a row boundary is omitted from that boundary to avoid awkward leading/trailing rules.
Suggested layouts: 32–40dip high for one row; roughly 72–90dip high for two rows, depending on spacing and custom views. These are layout examples, not automatic height guarantees. For a truly adaptive host, handle the parent layout's resize event and adjust the toolbar base size.
9. Colors, translucency and interaction effects
Commands.BackgroundColor = 0x00000000 ' Fully transparent
Commands.BorderColor = 0xFF324254
Commands.BorderWidth = 1dip
Commands.CornerRadius = 8dip
Commands.ButtonTextColor = 0xFF2D65BD
Commands.SeparatorColor = 0xFF778899
Commands.SeparatorWidth = 1dip
Commands.RippleEnabled = True
Commands.HoverFillEnabled = True
Commands.HoverColor = 0x00000000 ' Use derived hover color
Commands.SelectedColor = 0x00000000 ' Use derived selected color
ARGB values include an alpha channel, so semi-transparent backgrounds are supported. Background transparency does not by itself create an acrylic blur effect. HoverColor=transparent and SelectedColor=transparent are sentinel values that let the implementation derive suitable fills. GlowOnHover and GlowColor are compatibility aliases corresponding to earlier hover behavior; new code should prefer HoverFillEnabled and HoverColor.
10. Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
AddButton produces no visible item |
CustomView not added to a parent / Designer layout not loaded | Call AddToParent, or load the Designer layout before populating. |
| Second row is clipped | Toolbar host is too short | Increase the base height; Wrap does not resize its parent. |
| Button click appears to do nothing | Wrong callback prefix or element EventName | Use save_Click or Commands_ItemClick; see event-routing rule. |
AddMenuItem returns Null |
Parent identifier does not exist | Add the root menu or submenu before adding children. |
| Dropdown does not appear | Empty or disabled/invisible root menu | Add at least one item and verify the root's state. |
| Existing ComboBox seems to disappear from its old parent | Reparenting is intentional | Add a view only once and treat JToolBar as its new owner. |
| Image missing | Wrong Dir/filename or unbundled asset |
Add the file to the B4J Files tab and check spelling/case. |
| Tooltip or command updated on the wrong item | IDs are reused | Give every toolbar/menu element a stable unique EventName. |
11. Public API — exhaustive signatures and descriptions
The automatically verified reference below includes every Public Sub and Public Const present in the supplied JToolBar.bas, including property getter/setter pairs and compatibility aliases. Methods that return JavaObject expose native JavaFX objects for advanced integration. Ordinary application code should prefer the higher-level B4J methods illustrated above.
Complete source-verified reference: JToolBar
Declared events
-
ItemClick (EventName As String) -
TextFieldAction (EventName As String, Text As String)
These are events explicitly declared with #Event in this class. Public bridge functions without a corresponding #Event are not automatically consumer callbacks.
Designer properties and defaults
| Property key | Field type | Default / options | Meaning |
|---|
| Wrap | Boolean | True | Move items to another row when there is not enough horizontal space. |
| RowHeight | Int | 32 | Minimum total row height |
| Spacing | Int | 3 | Horizontal spacing between regular items. |
| SeparatorSpacing | Int | 4 | Space on both sides of each separator. |
| RowSpacing | Int | 0 | Vertical spacing between rows. |
| PaddingLeft | Int | 0 | Inner left padding. |
| PaddingRight | Int | 0 | Inner right padding. |
| PaddingTop | Int | 0 | Inner top padding. |
| PaddingBottom | Int | 0 | Inner bottom padding. |
| BackgroundColor | Color | 0x00FFFFFF | ARGB background color. Alpha is supported. |
| BorderColor | Color | 0x00000000 | Border color. |
| BorderWidth | Int | 0 | Border width. |
| CornerRadius | Int | 0 | Background corner radius. |
| SeparatorColor | Color | 0xFF808080 | Color used by separators. |
| SeparatorWidth | Int | 1 | Width of a vertical separator. |
| ButtonTextColor | Color | 0xFF3B82F6 | Default text color for buttons created by the toolbar. |
| RippleEnabled | Boolean | True | Animate button clicks with a ripple. |
| HoverFillEnabled | Boolean | True | Color the button background while the pointer is over it. |
| HoverColor | Color | 0x00000000 | Transparent derives a subtle fill from the toolbar background. |
| SelectedColor | Color | 0x00000000 | Transparent derives a stronger fill from the toolbar background. |
These keys configure a Designer CustomView. They are not automatically callable setters; check the public method list before writing Component.Property = value.
Public fields
Public Tag As Object
Prefer the documented methods/properties where offered. Public data fields can be mutable; changing them after a menu is rendered may not automatically refresh its layout.
All JToolBar Public Sub declarations (84)
JToolBar.Initialize
Public Sub Initialize (Callback As Object, EventName As String)
Initializes the callbacks and internal collections of a toolbar created from code. Call it before AddToParent.
Parameters:
Callback(Object): B4J object that receives the component events (normally Me).EventName(String): Unique, stable identifier used for command callbacks and later lookups.
Returns: no return value (Sub).
Lifecycle: normally called by framework initialization or by the code-created pattern; do not call the Designer lifecycle method again after LoadLayout.
JToolBar.DesignerCreateView
Public Sub DesignerCreateView (Base As Object, Lbl As Label, Props As Map)
Designer lifecycle entrypoint called when a CustomView layout is loaded. Users normally do not call it explicitly.
Parameters:
Base(Object): The view supplied by the B4J Designer.Lbl(Label): The Designer label carrying font and text settings.Props(Map): A Map of properties provided by the Designer.
Returns: no return value (Sub).
Lifecycle: normally called by framework initialization or by the code-created pattern; do not call the Designer lifecycle method again after LoadLayout.
JToolBar.AddToParent
Public Sub AddToParent (Parent As B4XView, Left As Int, Top As Int, Width As Int, Height As Int)
Creates a toolbar host panel inside an existing B4XView at the given position and size.
Parameters:
Parent(B4XView): Containing B4XView or existing tree parent, according to this method.Left(Int): The view's left coordinate in dip.Top(Int): Top coordinate or top-corner flag, as specified by the type.Width(Int): Width expressed in device-independent pixels (dip).Height(Int): Height expressed in device-independent pixels (dip).
Returns: no return value (Sub).
JToolBar.AddView
Public Sub AddView (View As Object)
Moves an existing native JavaFX view or compatible jdashboardUI CustomView into the toolbar, measuring its preferred size.
Parameters:
View(Object): The existing B4J/JavaFX view or compatible CustomView to use.
Returns: no return value (Sub).
JToolBar.AddView2
Public Sub AddView2 (View As Object, Width As Double, Height As Double)
Moves an existing view into the toolbar and supplies preferred width and height; nonpositive dimensions are measured.
Parameters:
View(Object): The existing B4J/JavaFX view or compatible CustomView to use.Width(Double): Width expressed in device-independent pixels (dip).Height(Double): Height expressed in device-independent pixels (dip).
Returns: no return value (Sub).
JToolBar.AddViewWithId
Public Sub AddViewWithId (Id As String, View As Object)
Compatibility alias for registering an existing view by ID. Prefer AddViewWithEventName.
Parameters:
Id(String): The item's stable identifier.View(Object): The existing B4J/JavaFX view or compatible CustomView to use.
Returns: no return value (Sub).
JToolBar.AddViewWithId2
Public Sub AddViewWithId2 (Id As String, View As Object, Width As Double, Height As Double)
Compatibility alias for registering an existing view by ID with dimensions. Prefer AddViewWithEventName2.
Parameters:
Id(String): The item's stable identifier.View(Object): The existing B4J/JavaFX view or compatible CustomView to use.Width(Double): Width expressed in device-independent pixels (dip).Height(Double): Height expressed in device-independent pixels (dip).
Returns: no return value (Sub).
JToolBar.AddViewWithEventName
Public Sub AddViewWithEventName (EventName As String, View As Object)
Registers and reparents an existing view under a stable EventName for GetItem, state changes and later removal.
Parameters:
EventName(String): Unique, stable identifier used for command callbacks and later lookups.View(Object): The existing B4J/JavaFX view or compatible CustomView to use.
Returns: no return value (Sub).
JToolBar.AddViewWithEventName2
Public Sub AddViewWithEventName2 (EventName As String, View As Object, Width As Double, Height As Double)
As above, with explicit preferred width and height.
Parameters:
EventName(String): Unique, stable identifier used for command callbacks and later lookups.View(Object): The existing B4J/JavaFX view or compatible CustomView to use.Width(Double): Width expressed in device-independent pixels (dip).Height(Double): Height expressed in device-independent pixels (dip).
Returns: no return value (Sub).
JToolBar.AddTextField
Public Sub AddTextField (EventName As String, Text As String, Width As Double, Editable As Boolean = True, PromptText As String = "") As TextField
Creates a styled native TextField with a stable EventName; pressing Enter in editable mode raises TextFieldAction.
Parameters:
EventName(String): Unique, stable identifier used for command callbacks and later lookups.Text(String): Text to display, search or insert, depending on the method.Width(Double): Width expressed in device-independent pixels (dip).Editable(Boolean): Whether typing is permitted in this text field. Default:True.PromptText(String): Placeholder shown when the field is empty. Default:"".
Returns: TextField. A newly created or resolved node/view object.
JToolBar.AddButton
Public Sub AddButton (EventName As String, Text As String, Icon As String = "", IconFont As Font = Null, IconColor As Int = 0xFF404040, ToolTipText As String = "", Enabled As Boolean = True, Visible As Boolean = True) As Button
Creates a text button with optional font glyph, tooltip, enabled/visible state and individual EventName_Click callback.
Parameters:
EventName(String): Unique, stable identifier used for command callbacks and later lookups.Text(String): Text to display, search or insert, depending on the method.Icon(String): Font-glyph character used in a button or node. Default:"".IconFont(Font): B4XFont/Font containing the chosen glyph. Default:Null.IconColor(Int): Color assigned to the glyph (usually ARGB). Default:0xFF404040.ToolTipText(String): Text shown to the user on hover. Default:"".Enabled(Boolean): Whether this command/control accepts user action. Default:True.Visible(Boolean): Whether this control or menu entry is displayed. Default:True.
Returns: Button. A newly created or resolved node/view object.
JToolBar.AddIconButton
Public Sub AddIconButton (EventName As String, Icon As String, IconFont As Font = Null, IconColor As Int = 0xFFF4F5F7, ToolTipText As String = "", Enabled As Boolean = True, Visible As Boolean = True) As Button
Creates a compact icon-only button using an icon font and configurable tooltip.
Parameters:
EventName(String): Unique, stable identifier used for command callbacks and later lookups.Icon(String): Font-glyph character used in a button or node.IconFont(Font): B4XFont/Font containing the chosen glyph. Default:Null.IconColor(Int): Color assigned to the glyph (usually ARGB). Default:0xFFF4F5F7.ToolTipText(String): Text shown to the user on hover. Default:"".Enabled(Boolean): Whether this command/control accepts user action. Default:True.Visible(Boolean): Whether this control or menu entry is displayed. Default:True.
Returns: Button. A newly created or resolved node/view object.
JToolBar.AddImageButton
Public Sub AddImageButton (EventName As String, ImageDir As String, ImageFileName As String, ToolTipText As String = "", Enabled As Boolean = True, Visible As Boolean = True) As Button
Creates a compact image-only button using a local image directory and filename.
Parameters:
EventName(String): Unique, stable identifier used for command callbacks and later lookups.ImageDir(String): Directory containing the image asset.ImageFileName(String): Name of image file stored in ImageDir.ToolTipText(String): Text shown to the user on hover. Default:"".Enabled(Boolean): Whether this command/control accepts user action. Default:True.Visible(Boolean): Whether this control or menu entry is displayed. Default:True.
Returns: Button. A newly created or resolved node/view object.
JToolBar.AddMenuButton
Public Sub AddMenuButton (EventName As String, Icon As String, IconFont As Font = Null, IconColor As Int = 0xFFF4F5F7, ToolTipText As String = "", Enabled As Boolean = True, Visible As Boolean = True) As Button
Creates a compact dropdown toolbar button and native JavaFX ContextMenu, identified by EventName.
Parameters:
EventName(String): Unique, stable identifier used for command callbacks and later lookups.Icon(String): Font-glyph character used in a button or node.IconFont(Font): B4XFont/Font containing the chosen glyph. Default:Null.IconColor(Int): Color assigned to the glyph (usually ARGB). Default:0xFFF4F5F7.ToolTipText(String): Text shown to the user on hover. Default:"".Enabled(Boolean): Whether this command/control accepts user action. Default:True.Visible(Boolean): Whether this control or menu entry is displayed. Default:True.
Returns: Button. A newly created or resolved node/view object.
JToolBar.AddMenuButton2
Public Sub AddMenuButton2 (EventName As String, Icon As String, IconFont As Font, IconColor As Int, ToolTipText As String, Width As Double, Height As Double, Enabled As Boolean = True, Visible As Boolean = True) As Button
Creates a dropdown button like AddMenuButton but with explicit minimum dimensions.
Parameters:
EventName(String): Unique, stable identifier used for command callbacks and later lookups.Icon(String): Font-glyph character used in a button or node.IconFont(Font): B4XFont/Font containing the chosen glyph.IconColor(Int): Color assigned to the glyph (usually ARGB).ToolTipText(String): Text shown to the user on hover.Width(Double): Width expressed in device-independent pixels (dip).Height(Double): Height expressed in device-independent pixels (dip).Enabled(Boolean): Whether this command/control accepts user action. Default:True.Visible(Boolean): Whether this control or menu entry is displayed. Default:True.
Returns: Button. A newly created or resolved node/view object.
JToolBar.AddMenuImageButton
Public Sub AddMenuImageButton (EventName As String, ImageDir As String, ImageFileName As String, ToolTipText As String = "", Enabled As Boolean = True, Visible As Boolean = True) As Button
Creates a dropdown button using an image file instead of an icon-font character.
Parameters:
EventName(String): Unique, stable identifier used for command callbacks and later lookups.ImageDir(String): Directory containing the image asset.ImageFileName(String): Name of image file stored in ImageDir.ToolTipText(String): Text shown to the user on hover. Default:"".Enabled(Boolean): Whether this command/control accepts user action. Default:True.Visible(Boolean): Whether this control or menu entry is displayed. Default:True.
Returns: Button. A newly created or resolved node/view object.
JToolBar.AddMenuItem
Public Sub AddMenuItem (ParentEventName As String, EventName As String, Text As String, Icon As String = "", IconFont As Font = Null, IconColor As Int = 0xFF404040, Enabled As Boolean = True, Visible As Boolean = True) As JavaObject
Adds a clickable native menu entry to an existing root dropdown or submenu.
Parameters:
ParentEventName(String): EventName of the existing parent dropdown or submenu.EventName(String): Unique, stable identifier used for command callbacks and later lookups.Text(String): Text to display, search or insert, depending on the method.Icon(String): Font-glyph character used in a button or node. Default:"".IconFont(Font): B4XFont/Font containing the chosen glyph. Default:Null.IconColor(Int): Color assigned to the glyph (usually ARGB). Default:0xFF404040.Enabled(Boolean): Whether this command/control accepts user action. Default:True.Visible(Boolean): Whether this control or menu entry is displayed. Default:True.
Returns: JavaObject. A newly created or resolved node/view object.
JToolBar.AddMenuImageItem
Public Sub AddMenuImageItem (ParentEventName As String, EventName As String, Text As String, ImageDir As String, ImageFileName As String, Enabled As Boolean = True, Visible As Boolean = True) As JavaObject
Adds an image-backed menu entry to an existing root dropdown or submenu.
Parameters:
ParentEventName(String): EventName of the existing parent dropdown or submenu.EventName(String): Unique, stable identifier used for command callbacks and later lookups.Text(String): Text to display, search or insert, depending on the method.ImageDir(String): Directory containing the image asset.ImageFileName(String): Name of image file stored in ImageDir.Enabled(Boolean): Whether this command/control accepts user action. Default:True.Visible(Boolean): Whether this control or menu entry is displayed. Default:True.
Returns: JavaObject. A newly created or resolved node/view object.
JToolBar.AddSubMenu
Public Sub AddSubMenu (ParentEventName As String, EventName As String, Text As String, Icon As String = "", IconFont As Font = Null, IconColor As Int = 0xFF404040, Enabled As Boolean = True, Visible As Boolean = True) As JavaObject
Creates a nested menu entry; its EventName becomes the parent ID for later children.
Parameters:
ParentEventName(String): EventName of the existing parent dropdown or submenu.EventName(String): Unique, stable identifier used for command callbacks and later lookups.Text(String): Text to display, search or insert, depending on the method.Icon(String): Font-glyph character used in a button or node. Default:"".IconFont(Font): B4XFont/Font containing the chosen glyph. Default:Null.IconColor(Int): Color assigned to the glyph (usually ARGB). Default:0xFF404040.Enabled(Boolean): Whether this command/control accepts user action. Default:True.Visible(Boolean): Whether this control or menu entry is displayed. Default:True.
Returns: JavaObject. A newly created or resolved node/view object.
JToolBar.AddMenuView
Public Sub AddMenuView (ParentEventName As String, EventName As String, View As Object, Width As Double = 0, Height As Double = 0, HideOnClick As Boolean = False) As JavaObject
Moves a native or custom B4J view into a menu entry. The original view retains its event handlers. HideOnClick determines whether interaction closes the popup.
Parameters:
ParentEventName(String): EventName of the existing parent dropdown or submenu.EventName(String): Unique, stable identifier used for command callbacks and later lookups.View(Object): The existing B4J/JavaFX view or compatible CustomView to use.Width(Double): Width expressed in device-independent pixels (dip). Default:0.Height(Double): Height expressed in device-independent pixels (dip). Default:0.HideOnClick(Boolean): Whether interaction with an embedded menu view closes the popup. Default:False.
Returns: JavaObject. A newly created or resolved node/view object.
JToolBar.AddMenuSeparator
Public Sub AddMenuSeparator (ParentEventName As String)
Adds a separator within a root dropdown or submenu, not the toolbar row.
Parameters:
ParentEventName(String): EventName of the existing parent dropdown or submenu.
Returns: no return value (Sub).
JToolBar.ShowMenu
Public Sub ShowMenu (EventName As String)
Opens an enabled, visible and nonempty root dropdown directly beneath its toolbar button.
Parameters:
EventName(String): Unique, stable identifier used for command callbacks and later lookups.
Returns: no return value (Sub).
JToolBar.HideMenus
Public Sub HideMenus
Closes all toolbar-managed dropdown popups.
Returns: no return value (Sub).
JToolBar.ClearMenu
Public Sub ClearMenu (ParentEventName As String)
Removes the child entries of a specified root dropdown or submenu without removing the toolbar itself.
Parameters:
ParentEventName(String): EventName of the existing parent dropdown or submenu.
Returns: no return value (Sub).
JToolBar.AddSeparator
Public Sub AddSeparator
Appends a vertical separator to the toolbar flow; wrapping may omit a separator at a row boundary.
Returns: no return value (Sub).
JToolBar.GetItem
Public Sub GetItem (EventName As String) As Object
Finds a registered toolbar control by EventName; returns the stored control object or Null.
Parameters:
EventName(String): Unique, stable identifier used for command callbacks and later lookups.
Returns: Object. A newly created or resolved node/view object.
JToolBar.SetButtonToggleOnClick
Public Sub SetButtonToggleOnClick (EventName As String, Enabled As Boolean)
Configures a toolbar-created button so a click toggles its persistent selected state.
Parameters:
EventName(String): Unique, stable identifier used for command callbacks and later lookups.Enabled(Boolean): Whether this command/control accepts user action.
Returns: no return value (Sub).
JToolBar.SetButtonSelected
Public Sub SetButtonSelected (EventName As String, Selected As Boolean)
Sets the selected appearance/state of a toggle button from application code.
Parameters:
EventName(String): Unique, stable identifier used for command callbacks and later lookups.Selected(Boolean): Selected or toggled state.
Returns: no return value (Sub).
JToolBar.GetButtonSelected
Public Sub GetButtonSelected (EventName As String) As Boolean
Reads a toolbar button’s selected state.
Parameters:
EventName(String): Unique, stable identifier used for command callbacks and later lookups.
Returns: Boolean. Success/failure status.
JToolBar.RemoveItem
Public Sub RemoveItem (EventName As String)
Removes a registered toolbar item by identifier and recomputes the layout.
Parameters:
EventName(String): Unique, stable identifier used for command callbacks and later lookups.
Returns: no return value (Sub).
JToolBar.SetEnabled
Public Sub SetEnabled (EventName As String, Enabled As Boolean)
Changes whether a registered toolbar/menu entry is enabled. Also available under SetItemEnabled.
Parameters:
EventName(String): Unique, stable identifier used for command callbacks and later lookups.Enabled(Boolean): Whether this command/control accepts user action.
Returns: no return value (Sub).
JToolBar.SetItemEnabled
Public Sub SetItemEnabled (EventName As String, Enabled As Boolean)
Changes enabled state for a registered toolbar item, custom view or menu entry.
Parameters:
EventName(String): Unique, stable identifier used for command callbacks and later lookups.Enabled(Boolean): Whether this command/control accepts user action.
Returns: no return value (Sub).
JToolBar.GetItemEnabled
Public Sub GetItemEnabled (EventName As String) As Boolean
Returns enabled state of an identified toolbar/menu entry.
Parameters:
EventName(String): Unique, stable identifier used for command callbacks and later lookups.
Returns: Boolean. Success/failure status.
JToolBar.SetVisible
Public Sub SetVisible (EventName As String, Visible As Boolean)
Changes visibility of a toolbar/menu element. Also available under SetItemVisible.
Parameters:
EventName(String): Unique, stable identifier used for command callbacks and later lookups.Visible(Boolean): Whether this control or menu entry is displayed.
Returns: no return value (Sub).
JToolBar.SetItemVisible
Public Sub SetItemVisible (EventName As String, Visible As Boolean)
Changes visibility and triggers toolbar reflow where applicable.
Parameters:
EventName(String): Unique, stable identifier used for command callbacks and later lookups.Visible(Boolean): Whether this control or menu entry is displayed.
Returns: no return value (Sub).
JToolBar.GetItemVisible
Public Sub GetItemVisible (EventName As String) As Boolean
Returns visibility state of an identified item.
Parameters:
EventName(String): Unique, stable identifier used for command callbacks and later lookups.
Returns: Boolean. Success/failure status.
JToolBar.SetItemToolTip
Public Sub SetItemToolTip (EventName As String, ToolTipText As String)
Adds, changes or removes tooltip text for the identified toolbar entry.
Parameters:
EventName(String): Unique, stable identifier used for command callbacks and later lookups.ToolTipText(String): Text shown to the user on hover.
Returns: no return value (Sub).
JToolBar.MoveItem
Public Sub MoveItem (EventName As String, NewIndex As Int)
Repositions a toolbar item within the full zero-based item list; separators count.
Parameters:
EventName(String): Unique, stable identifier used for command callbacks and later lookups.NewIndex(Int): Zero-based target position in the complete toolbar item sequence.
Returns: no return value (Sub).
JToolBar.Clear
Public Sub Clear
Removes all toolbar entries and their registered commands/menus.
Returns: no return value (Sub).
JToolBar.GetBase
Public Sub GetBase As B4XView
Returns the B4XView host of this JToolBar.
Returns: B4XView. The returned value; check readiness and validity as explained in the tutorial.
JToolBar.getWrap
Public Sub getWrap As Boolean
Returns the Wrap property. Moves toolbar entries onto additional rows when horizontal space is insufficient.
Returns: Boolean. Success/failure status.
JToolBar.setWrap
Public Sub setWrap (Value As Boolean)
Changes the Wrap property. Moves toolbar entries onto additional rows when horizontal space is insufficient.
Parameters:
Value(Boolean): The new value to apply to the property or operation.
Returns: no return value (Sub).
JToolBar.getRowHeight
Public Sub getRowHeight As Double
Returns the RowHeight property. Minimum row height; toolbar implementation enforces at least 32dip.
Returns: Double. The returned value; check readiness and validity as explained in the tutorial.
JToolBar.setRowHeight
Public Sub setRowHeight (Value As Double)
Changes the RowHeight property. Minimum row height; toolbar implementation enforces at least 32dip.
Parameters:
Value(Double): The new value to apply to the property or operation.
Returns: no return value (Sub).
JToolBar.getSpacing
Public Sub getSpacing As Double
Returns the Spacing property. The spacing configuration of this component.
Returns: Double. The returned value; check readiness and validity as explained in the tutorial.
JToolBar.setSpacing
Public Sub setSpacing (Value As Double)
Changes the Spacing property. The spacing configuration of this component.
Parameters:
Value(Double): The new value to apply to the property or operation.
Returns: no return value (Sub).
JToolBar.getSeparatorSpacing
Public Sub getSeparatorSpacing As Double
Returns the SeparatorSpacing property. Whitespace on both sides of a toolbar separator.
Returns: Double. The returned value; check readiness and validity as explained in the tutorial.
JToolBar.setSeparatorSpacing
Public Sub setSeparatorSpacing (Value As Double)
Changes the SeparatorSpacing property. Whitespace on both sides of a toolbar separator.
Parameters:
Value(Double): The new value to apply to the property or operation.
Returns: no return value (Sub).
JToolBar.getRowSpacing
Public Sub getRowSpacing As Double
Returns the RowSpacing property. Vertical gap between rows.
Returns: Double. The returned value; check readiness and validity as explained in the tutorial.
JToolBar.setRowSpacing
Public Sub setRowSpacing (Value As Double)
Changes the RowSpacing property. Vertical gap between rows.
Parameters:
Value(Double): The new value to apply to the property or operation.
Returns: no return value (Sub).
JToolBar.getPaddingLeft
Public Sub getPaddingLeft As Double
Returns the PaddingLeft property. The padding left configuration of this component.
Returns: Double. The returned value; check readiness and validity as explained in the tutorial.
JToolBar.setPaddingLeft
Public Sub setPaddingLeft (Value As Double)
Changes the PaddingLeft property. The padding left configuration of this component.
Parameters:
Value(Double): The new value to apply to the property or operation.
Returns: no return value (Sub).
JToolBar.getPaddingRight
Public Sub getPaddingRight As Double
Returns the PaddingRight property. The padding right configuration of this component.
Returns: Double. The returned value; check readiness and validity as explained in the tutorial.
JToolBar.setPaddingRight
Public Sub setPaddingRight (Value As Double)
Changes the PaddingRight property. The padding right configuration of this component.
Parameters:
Value(Double): The new value to apply to the property or operation.
Returns: no return value (Sub).
JToolBar.getPaddingTop
Public Sub getPaddingTop As Double
Returns the PaddingTop property. The padding top configuration of this component.
Returns: Double. The returned value; check readiness and validity as explained in the tutorial.
JToolBar.setPaddingTop
Public Sub setPaddingTop (Value As Double)
Changes the PaddingTop property. The padding top configuration of this component.
Parameters:
Value(Double): The new value to apply to the property or operation.
Returns: no return value (Sub).
JToolBar.getPaddingBottom
Public Sub getPaddingBottom As Double
Returns the PaddingBottom property. The padding bottom configuration of this component.
Returns: Double. The returned value; check readiness and validity as explained in the tutorial.
JToolBar.setPaddingBottom
Public Sub setPaddingBottom (Value As Double)
Changes the PaddingBottom property. The padding bottom configuration of this component.
Parameters:
Value(Double): The new value to apply to the property or operation.
Returns: no return value (Sub).
JToolBar.getBackgroundColor
Public Sub getBackgroundColor As Int
Returns the BackgroundColor property. The background color configuration of this component.
Returns: Int. The returned value; check readiness and validity as explained in the tutorial.
JToolBar.setBackgroundColor
Public Sub setBackgroundColor (Value As Int)
Changes the BackgroundColor property. The background color configuration of this component.
Parameters:
Value(Int): The new value to apply to the property or operation.
Returns: no return value (Sub).
JToolBar.getBorderColor
Public Sub getBorderColor As Int
Returns the BorderColor property. The border color configuration of this component.
Returns: Int. The returned value; check readiness and validity as explained in the tutorial.
JToolBar.setBorderColor
Public Sub setBorderColor (Value As Int)
Changes the BorderColor property. The border color configuration of this component.
Parameters:
Value(Int): The new value to apply to the property or operation.
Returns: no return value (Sub).
JToolBar.getBorderWidth
Public Sub getBorderWidth As Double
Returns the BorderWidth property. The border width configuration of this component.
Returns: Double. The returned value; check readiness and validity as explained in the tutorial.
JToolBar.setBorderWidth
Public Sub setBorderWidth (Value As Double)
Changes the BorderWidth property. The border width configuration of this component.
Parameters:
Value(Double): The new value to apply to the property or operation.
Returns: no return value (Sub).
JToolBar.getCornerRadius
Public Sub getCornerRadius As Double
Returns the CornerRadius property. The corner radius configuration of this component.
Returns: Double. The returned value; check readiness and validity as explained in the tutorial.
JToolBar.setCornerRadius
Public Sub setCornerRadius (Value As Double)
Changes the CornerRadius property. The corner radius configuration of this component.
Parameters:
Value(Double): The new value to apply to the property or operation.
Returns: no return value (Sub).
JToolBar.getSeparatorColor
Public Sub getSeparatorColor As Int
Returns the SeparatorColor property. The separator color configuration of this component.
Returns: Int. The returned value; check readiness and validity as explained in the tutorial.
JToolBar.setSeparatorColor
Public Sub setSeparatorColor (Value As Int)
Changes the SeparatorColor property. The separator color configuration of this component.
Parameters:
Value(Int): The new value to apply to the property or operation.
Returns: no return value (Sub).
JToolBar.getSeparatorWidth
Public Sub getSeparatorWidth As Double
Returns the SeparatorWidth property. The separator width configuration of this component.
Returns: Double. The returned value; check readiness and validity as explained in the tutorial.
JToolBar.setSeparatorWidth
Public Sub setSeparatorWidth (Value As Double)
Changes the SeparatorWidth property. The separator width configuration of this component.
Parameters:
Value(Double): The new value to apply to the property or operation.
Returns: no return value (Sub).
JToolBar.getButtonTextColor
Public Sub getButtonTextColor As Int
Returns the ButtonTextColor property. The button text color configuration of this component.
Returns: Int. The returned value; check readiness and validity as explained in the tutorial.
JToolBar.setButtonTextColor
Public Sub setButtonTextColor (Value As Int)
Changes the ButtonTextColor property. The button text color configuration of this component.
Parameters:
Value(Int): The new value to apply to the property or operation.
Returns: no return value (Sub).
JToolBar.getRippleEnabled
Public Sub getRippleEnabled As Boolean
Returns the RippleEnabled property. Whether generated toolbar buttons animate on click.
Returns: Boolean. Success/failure status.
JToolBar.setRippleEnabled
Public Sub setRippleEnabled (Value As Boolean)
Changes the RippleEnabled property. Whether generated toolbar buttons animate on click.
Parameters:
Value(Boolean): The new value to apply to the property or operation.
Returns: no return value (Sub).
JToolBar.getGlowOnHover
Public Sub getGlowOnHover As Boolean
Returns the GlowOnHover property. Legacy alias for HoverFillEnabled.
Returns: Boolean. Success/failure status.
JToolBar.setGlowOnHover
Public Sub setGlowOnHover (Value As Boolean)
Changes the GlowOnHover property. Legacy alias for HoverFillEnabled.
Parameters:
Value(Boolean): The new value to apply to the property or operation.
Returns: no return value (Sub).
JToolBar.getGlowColor
Public Sub getGlowColor As Int
Returns the GlowColor property. Legacy alias for HoverColor.
Returns: Int. The returned value; check readiness and validity as explained in the tutorial.
JToolBar.setGlowColor
Public Sub setGlowColor (Value As Int)
Changes the GlowColor property. Legacy alias for HoverColor.
Parameters:
Value(Int): The new value to apply to the property or operation.
Returns: no return value (Sub).
JToolBar.getHoverFillEnabled
Public Sub getHoverFillEnabled As Boolean
Returns the HoverFillEnabled property. Whether a hovered generated button has a filled background.
Returns: Boolean. Success/failure status.
JToolBar.setHoverFillEnabled
Public Sub setHoverFillEnabled (Value As Boolean)
Changes the HoverFillEnabled property. Whether a hovered generated button has a filled background.
Parameters:
Value(Boolean): The new value to apply to the property or operation.
Returns: no return value (Sub).
JToolBar.getHoverColor
Public Sub getHoverColor As Int
Returns the HoverColor property. Explicit hover background or transparent for automatic color derivation.
Returns: Int. The returned value; check readiness and validity as explained in the tutorial.
JToolBar.setHoverColor
Public Sub setHoverColor (Value As Int)
Changes the HoverColor property. Explicit hover background or transparent for automatic color derivation.
Parameters:
Value(Int): The new value to apply to the property or operation.
Returns: no return value (Sub).
JToolBar.getSelectedColor
Public Sub getSelectedColor As Int
Returns the SelectedColor property. Explicit selected background or transparent for automatic color derivation.
Returns: Int. The returned value; check readiness and validity as explained in the tutorial.
JToolBar.setSelectedColor
Public Sub setSelectedColor (Value As Int)
Changes the SelectedColor property. Explicit selected background or transparent for automatic color derivation.
Parameters:
Value(Int): The new value to apply to the property or operation.
Returns: no return value (Sub).