### MenuBar build via Code

This example shows how to build a MenuBar via B4J code.
`Sub Process_Globals
Private fx As JFX
Private MainForm As Form
End Sub`
`Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.Show
Dim mb As MenuBar
mb.Initialize("")
MainForm.RootPane.AddNode(mb, 0, 0, 0,0)
Dim ports As Menu
ports.Initialize("Ports", "")
Dim FileMenu As Menu
FileMenu.Initialize("FileMenu", "")
mb.Menus.Add(FileMenu)
FileMenu.MenuItems.Add(ports)
For Each m As String In Array As String("a", "b", "c")
Dim mm As MenuItem
mm.Initialize(m, "mm")
ports.MenuItems.Add(mm)
Next
End Sub`
`Sub mm_Action
Dim mi As MenuItem = Sender
Log(mi.Text)
End Sub`
`Sub Test
For Each m As String In Serial1.ListPorts
Dim mm As CheckMenuItem
mm.Initialize(m, "mm")
mnuComPort.MenuItems.Add(mm)
If m = ValueLoadedFromFile Then mm.Selected = True
Next
End Sub`

Changed: , Category: Menu, File: T6C220M1615.htm, ID: 1615