B4J Question Get Pane- Tab Control

ykucuk

Well-Known Member
Licensed User
Longtime User
Hello,

How can I access to the pane in the Tab Page?

is there similar with
B4X:
 GetAllViewsRecursive
?
 

jmon

Well-Known Member
Licensed User
Longtime User
Hi,

Yes you can do it like that (Need JavaObject):

B4X:
Sub GetTabPanePages(Target As TabPane) As List
    Dim joTarget As JavaObject = Target
    Return joTarget.RunMethod("getTabs", Null)
End Sub

B4X:
For Each v As TabPage In GetTabPanePages(tp)
 Log(v.Text)
Next
 
Upvote 0

ykucuk

Well-Known Member
Licensed User
Longtime User
Hi,

Yes you can do it like that (Need JavaObject):

B4X:
Sub GetTabPanePages(Target As TabPane) As List
    Dim joTarget As JavaObject = Target
    Return joTarget.RunMethod("getTabs", Null)
End Sub

B4X:
For Each v As TabPage In GetTabPanePages(tp)
 Log(v.Text)
Next

Thanks for the reply but exactly I asked about how to access Pane in the second Tab Page in the tab control.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Thanks for the reply but exactly I asked about how to access Pane in the second Tab Page in the tab control.
No one is stopping you from using a counter in the loop
B4X:
dim counter as int = 0
For Each v As TabPage In GetTabPanePages(tp)
  if counter=1 then
     Log(v.Text)
  end if
 counter = counter+1
Next
 
Upvote 0

jmon

Well-Known Member
Licensed User
Longtime User
how to access Pane in the second Tab Page
Hi, you can do it like that, Like DonManFred said:
B4X:
Dim count As Int = 0
For Each p As TabPage In tp.Tabs
    If count = 1 Then
        Dim btn As Button
        btn.Initialize("")
        btn.Text = $"Button added to page 2!"$       
        p.Content.AddNode(btn, 50, 50, 200, 100)
    End If   
    count = count + 1
Next
tp.SelectedIndex = 1

Here that creates a button on the second page (page index 1, because the first page is index 0). So the pane of the TabPage is accessed via "p.Content".

By the way, I don't know why I went as far as using JavaObject in the first example, but to access the tabs, just use:
B4X:
tp.Tabs
Instead of the code I wrote above o_O
 
Upvote 0
Top