B4J Question How can I pass a tabpage array from a class into another?

Cableguy

Expert
Licensed User
Longtime User
Hi guys.

I'm trying to divide ( to conquer) my huge project into several modular modules (lol).
each module will pass an array of tabpages into Main.
I was successful in passing a single tabpage, but am getting casting errors while trying to pass an array of tabpages.

java.lang.ClassCastException: anywheresoftware.b4j.objects.TabPaneWrapper$TabWrapper cannot be cast to javafx.scene.control.Tab

some code:

B4X:
    PreviewPane.Tabs.Add( ButtonNode.PreviewTab) 'This gets a single tabpage, and works great
    PropertiesPane.Tabs.AddAll(Array As TabPage( ButtonNode.PropertiesTabs )) ' I have tried many variation of this, including in the returning sub, but no avail

The returning subs (from a class)

B4X:
Public Sub Initialize
    ' set the Preview Tab
    '************************************************
    PreviewPane.Initialize("")
    PreviewPane.LoadLayout("PreviewPage1")
    PreviewPage.Initialize                                                 'This is a single Tabpage to be passed
    PreviewPage.Text = "Button"
    PreviewPage.Content=PreviewPane
    '************************************************
  
    ' set the Properties Tabs
    '************************************************
    Dim PropertiesPane(1) As Pane
    Dim PropertiesPage(1) As TabPage
    For n = 0 To PropertiesPane.Length - 1
        PropertiesPane(n).Initialize("")
        PropertiesPage(n).Initialize
        PropertiesPage(n).Content=PreviewPane                'This will be an Array of tabPages
    Next
  

    PropertiesPane(0).LoadLayout("PropertiesPage1")
    PropertiesPage(0).Text = "Background"
  
    '************************************************
End Sub

Public Sub getPreviewTab As TabPage
    Return PreviewPage 'This passes 1 tabpage, works OK
End Sub

Public Sub getPropertiesTabs() As TabPage()
Return PropertiesPage 'I have tried several things, cannot pass it as array of tabpages
End Sub

Please Help!!
 
Last edited:

Cableguy

Expert
Licensed User
Longtime User
I can't exactly understand why I needed to do it this way, but it works

B4X:
    For n = 0 To ButtonNode.PropertiesTabs.Length - 1
        PropertiesPane.Tabs.Add(ButtonNode.PropertiesTabs(n))
    Next
I started by logging the returned array Length, which had the correct value, so the array was being correctly passed.
So I decided to iterate through it and add each tab, one at a time.
 
Upvote 0
Top