B4J Tutorial MenuBar Icons on MainTitle Menu

Hello,
my Task was to substitute the Title Menus with an Icon or to add an Icon to the text.
I found a good solution in the Forum as a base and modfied it to solve the task.

Place this code in the page with the menubar:
private Sub setMnuLabel(MenuNr As Int, Image As String)
    Dim jo As JavaObject = MenuBar.Menus.Get(MenuNr)
    Dim imv As ImageView
    imv.Initialize("MnuTitle")
    imv.SetImage(fx.LoadImageSample(File.DirAssets,Image,36,36))
    jo.RunMethod("setGraphic",Array(imv))
End Sub

Set the Icon after the Menu creation is completed::
'Example 1st left Menu'
setMnuLabel(0,"icons8-application-48.png") 'App

The Title Menus are numbered from left to right startet by 0 for the 1st left menu.

Example:
1759132513265.png


Notice! Menu Title Menus do not throw a click event neither do them with this solution.
 
Top