B4J Question [SOLVED] Closable and Non-closable tag pages with layouts

Discussion in 'B4J Questions' started by mfstuart, Mar 2, 2018.

  1. mfstuart

    mfstuart Active Member Licensed User

    Hi all,
    I'm trying to build a B4J desktop app that will have a tabpane with user added tabpages.
    When the app starts it will have a default "Home" tabpage which will not be closable.
    Any tabpage added by a user from clicking a "menu" option from a ListView, will be able to be closed by the user - it will have an x button on the tab.
    The trouble is I can get this user interface to work, but I can't get the "Home" page to load a layout, but with all other pages, I can load a layout to it.

    I've attached an example B4J app to show what I'm trying to do. and I explain more in the app about this issue.

    Can someone look at this and see what I need to do to get a layout associated to the Home page and the tab to not be closed by the user - no x button?

    Thanx,
    Mark Stuart
     

    Attached Files:

  2. Daestrum

    Daestrum Well-Known Member Licensed User

    Just use
    Code:
    pane.LoadLayout(LayoutName,tabname)

    to load the tabs
    and this after you have loaded the home tab (which I assume to be the first tab)

    Code:
    Dim jo as JavaObject = TabPane1.Tabs.Get(0)
    jo.RunMethod(
    "setClosable",Array(False))
    I think where you execute this code (below) for each added tab it overwrites the setting for the 'Home' tab
    Executing it once will set it for all tabs (as far as I can determine) it can be executed even before you add any tabs.
    Code:
    Dim jo As JavaObject = pane
     jo.RunMethod(
    "setTabClosingPolicy"Array("ALL_TABS"))
    Tiny example attached
     

    Attached Files:

    Last edited: Mar 3, 2018
    mfstuart likes this.
  3. mfstuart

    mfstuart Active Member Licensed User

    Hi Daestrum,
    Thanx for giving me a solution to the issue.
    I did make a small change to your sample, where I moved the call to make the closable on the "Home" page before loading the other tabs and layouts, as it simulates the user adding (eg: by clicking a button) the other tabs in the order that it may happen.

    Code:
    Sub AppStart (Form1 As Form, Args() As String)
        MainForm = Form1
        MainForm.RootPane.LoadLayout(
    "lay1"'Load the layout file.
        MainForm.Show
        asJO(TabPane1).RunMethod(
    "setTabClosingPolicy"Array("ALL_TABS"))
        TabPane1.LoadLayout(
    "lay2","Home")
        asJO(TabPane1.Tabs.Get(
    0)).RunMethod("setClosable",Array(False))
       
        TabPane1.LoadLayout(
    "lay3","User")
        TabPane1.LoadLayout(
    "lay2","Extra")
        TabPane1.LoadLayout(
    "lay3","Extra2")
        
    'asJO(TabPane1.Tabs.Get(0)).RunMethod("setClosable",Array(False))
    End Sub
    Thanx,
    Mark Stuart
     
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