B4J Question reorganization of column in the tableview

Erel

B4X founder
Staff member
Licensed User
Longtime User
Try this:
B4X:
Sub Process_Globals
   Private fx As JFX
   Private MainForm As Form
   Private tv As TableView
   Private suspended As Boolean
   Private items As List
End Sub

Sub AppStart (Form1 As Form, Args() As String)
   MainForm = Form1
   MainForm.Show
   tv.Initialize("tv")
   
   MainForm.RootPane.AddNode(tv, 10, 10, 400, 400)
   items.Initialize
   For i = 1 To 100
     items.Add(Array(i, i + 1, i + 2))
   Next
   SetTable
   Dim jo As JavaObject = tv
   Dim e As Object = jo.CreateEvent("javafx.collections.ListChangeListener", "colchange", Null)
   jo.RunMethodJO("getColumns", Null).RunMethod("addListener", Array(e))
End Sub

Sub SetTable
   tv.SetColumns(Array("col1", "col2", "col3"))
   tv.items = items
   tv.SetColumnWidth(0,100)
   tv.SetColumnWidth(1,100)
   tv.SetColumnWidth(2,100)
End Sub

Sub colchange_Event (MethodName As String, Args() As Object) As Object
   Dim change As JavaObject = Args(0)
   change.RunMethod("next", Null)
   If change.RunMethod("wasReplaced", Null) AND Not(suspended) Then
     suspended = True
     SetTable
     suspended = False
   End If
   Return Null
End Sub
 
Upvote 0
Top