B4J Question How to insert a separator in B4J MenuBar [solved]

Discussion in 'B4J Questions' started by Didier9, Jun 11, 2019.

  1. Didier9

    Didier9 Active Member Licensed User

    in this post: https://www.b4x.com/android/forum/threads/designer-menu-items.56602/#content Erel indicates
    I have not managed to make this work. Tried this:
    Code:
    Sub Process_Globals
        
    Private fx As JFX
        
    Private MainForm As Form
        
        
    Dim mb As MenuBar
    End Sub ' Process_Globals

    Sub AppStart( Form1 As Form, Args() As String )
        
        MainForm = Form1
        MainForm.RootPane.LoadLayout( 
    "Main" ) 'Load the layout file.
        MainForm.Show
        
        mb.Initialize( 
    "" )
        MainForm.RootPane.AddNode( mb, 
    00, -1, -1 )

        
    ' Add Settings menu to menu bar
        Dim SettingsMenu As Menu
        SettingsMenu.Initialize( 
    "Settings""" )
        mb.Menus.Add( SettingsMenu )
        
    ' Add Serial Ports submenu to Settings menu
        Dim SerialPort As Menu
        SerialPort.Initialize( 
    "Ports""" )
        SettingsMenu.MenuItems.Add( SerialPort )
        
    ' add Baud Rates
        Dim mnBaudrates As Menu
        mnBaudrates.Initialize( 
    "Baudrates""" )
        SettingsMenu.MenuItems.Add( mnBaudrates )
        
    ' add separator
        Dim s As String = "-"
        SettingsMenu.MenuItems.Add( s )
        
    ' add COM TimeOut
        Dim m As MenuItem
        m.Initialize( 
    "COM Time Out""mCOMTimeOut" )
        SettingsMenu.MenuItems.Add( m )

    End Sub
    which crashes, and this (with varying number of -):
    Code:
    ' add separator
        Dim m As MenuItem
        m.Initialize( 
    "-""" )
        SettingsMenu.MenuItems.Add( m )
    which does not crash but does not produce a normal separator.

    Could I have an example of what to insert into the menu structure to create a separator?
    TIA
     
  2. Daestrum

    Daestrum Well-Known Member Licensed User

    Try
    Code:
    Dim s As JavaObject
     s.InitializeNewInstance(
    "javafx.scene.control.SeparatorMenuItem",Null)
     SettingsMenu.MenuItems.Add( s )
     
    Didier9 likes this.
  3. Didier9

    Didier9 Active Member Licensed User

    Thank you!
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice