B4J Question Tab Page Scrollable

Discussion in 'B4J Questions' started by StarinschiAndrei, Jun 14, 2015.

  1. StarinschiAndrei

    StarinschiAndrei Active Member Licensed User

    Hi ,

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

    Thank you,
     
  2. jmon

    jmon Well-Known Member Licensed User

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

    klaus Expert Licensed User

    Have a look HERE.
     
  4. jmon

    jmon Well-Known Member Licensed User

    I think he meant on B4J didn't he?
     
  5. klaus

    klaus Expert Licensed User

    Oups, I didn't notice that it is for B4J.
     
  6. StarinschiAndrei

    StarinschiAndrei Active Member Licensed User

    Yes i would like to do in B4J , not in B4A
     
  7. StarinschiAndrei

    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
    Code:
    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
     

    Attached Files:

  8. Erel

    Erel Administrator Staff Member Licensed User

    1. Call tPage.Content = scp
    2. Don't initialize ap. You are creating a new, unrelated, pane.
     
  9. StarinschiAndrei

    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()));
    Code:
    tPage.Initialize
    'ap.Initialize("")
        tbp.Tabs.Clear
        tPage.Content=scp
        ap.Style=
    "-fx-background-color:#404040"
        tbp.Tabs.Add(tPage)
     
  10. Erel

    Erel Administrator Staff Member Licensed User

    I see. You need to create another AnchorPane that will be the page content. Add the ScrollPane to the new AnchorPane.
     
  11. StarinschiAndrei

    StarinschiAndrei Active Member Licensed User

    I think i don't understand something well, because it behave similar as before. Below the new code :
    Code:
    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
     
  12. Erel

    Erel Administrator Staff Member Licensed User

    Can you upload your project (File - Export as zip)?
     
  13. StarinschiAndrei

    StarinschiAndrei Active Member Licensed User

    Yes , here is the test project
     

    Attached Files:

  14. Erel

    Erel Administrator Staff 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.
     
  15. StarinschiAndrei

    StarinschiAndrei Active Member Licensed User

    After many test i did it , thank you Erel. attached the test project (scrollable anchor pane and tabpage )
     

    Attached Files:

    Erel likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice