B4J Question Scrollbar in a TableView

T201016

Active Member
Licensed User
Longtime User
I'm trying to access a scrollbar in a TableView to examine its actual values (from 0.0 to 1.0)
when scrolling with the mouse, and I wonder if there is an easy way to do it?
Screen.png
 
Solution
I just figured out the problem, and here's the solution:
1. The first step is to call the procedure "ScrollChangedEvent";
2. In step two, examining the current position using: "Sub tbvSearch1_ScrollPosition_Changed"

Dim tbvSearch1 As TableView:
Sub ScrollChangedEvent
    Dim jo As JavaObject
    jo = tbvSearch1
    Dim nodes() As Object
    nodes = jo.RunMethodJO("lookupAll",Array(".scroll-bar")).RunMethod("toArray",Null)
    Dim TableViewScrollBar As JavaObject
 
    For Each sb As Object In nodes
        Dim sbJO As JavaObject
        sbJO = sb
        Dim orientation As String = sbJO.RunMethod("getOrientation",Null)
        If orientation = "VERTICAL" Then
            TableViewScrollBar = sbJO
        End If
    Next
 
    Dim r As Reflector
    r.Target =...

T201016

Active Member
Licensed User
Longtime User
I just figured out the problem, and here's the solution:
1. The first step is to call the procedure "ScrollChangedEvent";
2. In step two, examining the current position using: "Sub tbvSearch1_ScrollPosition_Changed"

Dim tbvSearch1 As TableView:
Sub ScrollChangedEvent
    Dim jo As JavaObject
    jo = tbvSearch1
    Dim nodes() As Object
    nodes = jo.RunMethodJO("lookupAll",Array(".scroll-bar")).RunMethod("toArray",Null)
    Dim TableViewScrollBar As JavaObject
 
    For Each sb As Object In nodes
        Dim sbJO As JavaObject
        sbJO = sb
        Dim orientation As String = sbJO.RunMethod("getOrientation",Null)
        If orientation = "VERTICAL" Then
            TableViewScrollBar = sbJO
        End If
    Next
 
    Dim r As Reflector
    r.Target = TableViewScrollBar
    r.AddChangeListener("tbvSearch1_ScrollPosition","valueProperty")
End Sub

Sub tbvSearch1_ScrollPosition_Changed(OldVal As Object, NewVal As Object)
    Log(NewVal.As(Double))
End Sub
 
Last edited:
Upvote 0
Solution
Top