B4J Question Add page to tabpane as b4xview

StarinschiAndrei

Active Member
Licensed User
Longtime User
Hi comunity, could anybody help me, how can i add a page to tabpane (as b4xview).I made a small test app but i receive the following error:
B4X:
java.lang.ClassCastException: class javafx.scene.control.TabPane cannot be cast to class javafx.scene.layout.Pane (javafx.scene.control.TabPane is in module javafx.controls of loader 'app'; javafx.scene.layout.Pane is in module javafx.graphics of loader 'app')
Thank you
 

Attachments

  • test.zip
    3.4 KB · Views: 154

William Lancee

Well-Known Member
Licensed User
Longtime User
Hello, we're in a different time zone, so I am just seeing this.
I tested my solution and it worked here. But I was wrong.
The problem is that you have the TabPane defined as a general B4XView. That means that the specific features of TabPane are not avaliable

Just define tp as TabPane in the Main routine and change things back to the way you had it. It will work as expected.

Note that the loadlayout of TabPane has an extra parameter, which is the title on the Tab.

B4X:
    Main.tp.LoadLayout("2", "12345")

You also have to modify your main. Tabs are created by the TabPane, not externally by you. Remove the buttons from Layout1

B4X:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private xui As XUI
  
    Public tp As TabPane
    Private newtab As new_tab
    Private newtab2 As tab2
End Sub

Sub AppStart(Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
    newtab.Initialize
    newtab2.Initialize
End Sub
 
Last edited:
Upvote 0

StarinschiAndrei

Active Member
Licensed User
Longtime User
Hello, we're in a different time zone, so I am just seeing this.
I tested my solution and it worked here. But I was wrong.
The problem is that you have the TabPane defined as a general B4XView. That means that the specific features of TabPane are not avaliable

Just define tp as TabPane in the Main routine and change things back to the way you had it. It will work as expected.

Note that the loadlayout of TabPane has an extra parameter, which is the title on the Tab.

B4X:
    Main.tp.LoadLayout("2", "12345")

You also have to modify your main. Tabs are created by the TabPane, not externally by you. Remove the buttons from Layout1

B4X:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private xui As XUI
 
    Public tp As TabPane
    Private newtab As new_tab
    Private newtab2 As tab2
End Sub

Sub AppStart(Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
    newtab.Initialize
    newtab2.Initialize
End Sub
THANK YOU
 
Upvote 0
Top