B4J Question TabPage inside TabPage

PatrikCavina

Active Member
Licensed User
Hi to everyone,
i'm trying to insert TabPage inside tabPage with recursive method.
Everything to create different levels of tabPage inside another.
Code is:
B4X:
Sub b(tabPage As TabPage) As Pane
    Dim pane As Pane
    pane.Initialize("")
    Dim tabPane As TabPane
    tabPane.Initialize("")
   
    pane.AddNode(tabPane,0,0,600,600)
    tabPane.Tabs.Add(tabPage)
   
    tabPage.Text = "lv"&increment
    If increment < lv Then
        increment = increment + 1
        Dim t As TabPage
        t.Initialize
        tabPage.Content = b(t)
    End If
    Return pane
End Sub

But at last call of the function i receive an error:
B4X:
Waiting for debugger to connect...
Program started.
java.lang.IllegalArgumentException: Children: cycle detected: parent = TabPane@471bf3b9[styleClass=tab-pane], node = TabPaneSkin$TabContentRegion@43c41713[styleClass=tab-content-area]
    at javafx.scene.Parent$2.onProposedChange(Parent.java:445)
    at com.sun.javafx.collections.VetoableListDecorator.add(VetoableListDecorator.java:317)
    at com.sun.javafx.scene.control.skin.TabPaneSkin.addTabContent(TabPaneSkin.java:428)
    at com.sun.javafx.scene.control.skin.TabPaneSkin.<init>(TabPaneSkin.java:191)
    at javafx.scene.control.TabPane.createDefaultSkin(TabPane.java:517)
    at javafx.scene.control.Control.impl_processCSS(Control.java:872)
    at javafx.scene.Parent.impl_processCSS(Parent.java:1280)
    at javafx.scene.Parent.impl_processCSS(Parent.java:1280)
    at javafx.scene.Parent.impl_processCSS(Parent.java:1280)
    at javafx.scene.control.Control.impl_processCSS(Control.java:868)
    at javafx.scene.Node.processCSS(Node.java:9058)
    at javafx.scene.Node.processCSS(Node.java:9051)
    at javafx.scene.Scene.doCSSPass(Scene.java:545)
    at javafx.scene.Scene.access$3600(Scene.java:159)
    at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2392)
    at com.sun.javafx.tk.Toolkit.lambda$runPulse$30(Toolkit.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:354)
    at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:381)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:510)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:490)
    at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$404(QuantumToolkit.java:319)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
    at java.lang.Thread.run(Thread.java:745)
 

PatrikCavina

Active Member
Licensed User
I've solve the problem, but now i need identify every tabPane created. Any tips?
B4X:
Private Sub SetLevelTabPane(tPane As TabPane)
    If tPane.Width <> 0 Then
        tabPaneHeight = tPane.Width
    Else
        tabPaneHeight = tabPaneHeight - 100
    End If
    Dim pane As Pane
    Dim newTPane As TabPane
    pane.Initialize("NewTabPane")
    newTPane.Initialize("")
    pane.AddNode(newTPane,0,0,tabPaneHeight,-1)
   
    Dim tPage As TabPage
    tPage.Initialize
    tPage.Tag = increase
    tPage.Text = "Lv"&increase
    tPage.Content = pane
   
    tPane.Tabs.Add(tPage)
    If increase < lv Then
        increase = increase + 1
        SetLevelTabPane(newTPane)
    End If
End Sub
End Sub
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
SS-2017-08-31_18.02.39.png


Complete code:
B4X:
Sub AppStart (Form1 As Form, Args() As String)
   MainForm = Form1
   MainForm.Show
   MainForm.RootPane.LoadLayout("Main")
   TabPaneMain.LoadLayout("MainPage1", "MainPage1")
   TabPanePage1.LoadLayout("Page1Child1", "Page1Child1")
End Sub

Notice how all views are resized automatically when the form is resized (based on the anchors).
 

Attachments

  • 1.zip
    3.4 KB · Views: 307
Upvote 0

PatrikCavina

Active Member
Licensed User
Thank you @Erel.
If i need to set undefined number of TabPane inside MainPane, can i use an array of TabPanePage and a recursive method to do it?
 
Upvote 0
Top