B4J Question Tab Page Scrollable

jmon

Well-Known Member
Licensed User
Hi ,

Can anybody tell me how can i make a tab page scrollable ?

Thank you,
Hi, you need to put a scrollpane inside your tabpage. Then you can add items in the rootpane of the scrollpane.
 

StarinschiAndrei

Active Member
Licensed User
i made some test but i can make the tab page scrollable, any idea what should i try ?
below my test and result
B4X:
Sub btntest_MouseClicked (EventData As MouseEvent)
Dim scp As ScrollPane
scp.Initialize("scp")
scp.SetVScrollVisibility("ALWAYS")
Dim tPage As TabPage
Dim ap As AnchorPane=scp.InnerNode
tPage.Initialize
ap.Initialize("")
    tbp.Tabs.Clear
    tPage.Content=ap
    ap.Style="-fx-background-color:#404040"
    tbp.Tabs.Add(tPage)
    tPage.Text="Test"
        For x=0 To 10
            Dim lbl As Button
                lbl.Initialize("lbl")
                lbl.PrefWidth =160
                lbl.prefHeight =40
                lbl.WrapText =True
                lbl.Style =" -fx-background-color:#313131; -fx-font-family: Tahoma;-fx-font-weight: bold; -fx-font-size: 14px; -fx-alignment: CENTER;"
                lbl.TextColor =fx.Colors.Black
                lbl.Text ="test "&x   
            ap.AddNode(lbl,0,x*40,160,40)
            ap.PrefHeight=x*lbl.PrefHeight
            Log(ap.PrefHeight)  
        Next
End Sub
 

Attachments

StarinschiAndrei

Active Member
Licensed User
I made the changes and now i have the following error :
B4J version: 3.02
Parsing code. (0.00s)
Compiling code. (0.04s)
Compiling generated Java code. Error
B4J line: 40
tPage.Content=scp
javac 1.8.0_45
src\b4j\example\main.java:208: error: incompatible types: ScrollPane cannot be converted to Pane
_tpage.setContent((javafx.scene.layout.Pane)(_scp.getObject()));
B4X:
tPage.Initialize
'ap.Initialize("")
    tbp.Tabs.Clear
    tPage.Content=scp
    ap.Style="-fx-background-color:#404040"
    tbp.Tabs.Add(tPage)
 

StarinschiAndrei

Active Member
Licensed User
I see. You need to create another AnchorPane that will be the page content. Add the ScrollPane to the new AnchorPane.
I think i don't understand something well, because it behave similar as before. Below the new code :
B4X:
Dim scp As ScrollPane
scp.Initialize("scp")
scp.SetVScrollVisibility("ALWAYS")
Dim tPage As TabPage
Dim ap As AnchorPane=scp.InnerNode
Dim apContent As AnchorPane
apContent.Initialize("")
tPage.Initialize
'ap.Initialize("")
    tbp.Tabs.Clear
    apContent.AddNode(ap,0,0,-1,-1)
    tPage.Content=apContent
    ap.Style="-fx-background-color:#404040"
    apContent.Style="-fx-background-color:#606060"
    tbp.Tabs.Add(tPage)
    tPage.Text="Test"
        For x=0 To 10
            Dim lbl As Button
                lbl.Initialize("lbl")
                lbl.PrefWidth =160
                lbl.prefHeight =40
                lbl.WrapText =True
                lbl.Style =" -fx-background-color:#313131; -fx-font-family: Tahoma;-fx-font-weight: bold; -fx-font-size: 14px; -fx-alignment: CENTER;"
                lbl.TextColor =fx.Colors.Black
                lbl.Text ="test "&x    
            apContent.AddNode(lbl,0,x*40,160,40)
            apContent.PrefHeight=x*lbl.PrefHeight
            Log(ap.PrefHeight)   
        Next
 

StarinschiAndrei

Active Member
Licensed User
1. You didn't add the ScrollPane to apContent. You added the inner node which is a mistake.
2. You should add the other nodes to ap (the inner node).
3. You should set the inner node size, not apContent.
After many test i did it , thank you Erel. attached the test project (scrollable anchor pane and tabpage )
 

Attachments

Top