B4J Question dynamic TabPage resize

madru

Active Member
Licensed User
Longtime User
Hi,

I am creating TabPage's dynamically like in the attached code, question is how can I resize those when the Form is resized?

THX

B4X:
    For Each v As JavaObject In MainForm.RootPane.GetAllViewsRecursive

        If v Is TabPane Then
   
            Dim t As TabPane = v
       
            Private tp1 As TabPage
            tp1 = addTabPage(v,"Tab A")

            tp1.Tag=1
            Dim tv As TableView
            tv.Initialize("")
            Dim cols As List

            cols.Initialize
            cols.AddAll(Array As String("a","b","c","d","e"))
            tv.SetColumns(cols)
            tv.SetColumnWidth(0,100)
            tv.SetColumnWidth(1,100)
            tv.SetColumnWidth(2,100)
            tv.SetColumnWidth(3,100)
            tv.SetColumnWidth(4,100)
            tv.Tag="dummy"
   
            tp1.Content.AddNode(tv,0,0,t.Width,t.Height)
        End If
   
    Next
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
I think it may be better to have a layout with its controls anchors set manually.

But for your example.

B4X:
    Dim tb As TabPage
    tb.Initialize
    tb.Text = "First"
   
    Dim ap As AnchorPane
    ap.Initialize("")
   
    tb.Content = ap
   
    Dim tv As TableView
    tv.Initialize("")
    Dim cols As List

    cols.Initialize
    cols.AddAll(Array As String("a","b","c","d","e"))
    tv.SetColumns(cols)
    tv.SetColumnWidth(0,100)
    tv.SetColumnWidth(1,100)
    tv.SetColumnWidth(2,100)
    tv.SetColumnWidth(3,100)
    tv.SetColumnWidth(4,100)
    tv.Tag="dummy"
   
    ap.AddNode(tv,0,0,-1,1)
    ap.setanchors(tv,5,5,5,5)
   
    TabPane1.Tabs.Add(tb)
 
Upvote 0
Top