B4J Question TableView with Anchorpanes

Patent

Member
Licensed User
Longtime User
Dear Guys,

I am using a TableView with anchorpanes and labels in.
Works well.

Problem:
I want to get the anchorpanes and the labels to get the labels text.

I dont want to use:
B4X:
Sub mytableview_SelectedRowChanged.......
because i want to "read out" any row without focusing.

I tryed:
B4X:
Dim a() AsObject
a=mytableview.Items.Get(myrow)

this returns Objects (as expectetd), but only the Name of the Pane (as string i.e. AnchorPane@1e97eff), not the pane itself (i.e. (AnchorPane) AnchorPane@1e97eff).


Any Ideas?


Greets
patent
 

Daestrum

Expert
Licensed User
Longtime User
Assuming the anchorpane is in col 0

dim myPane as AnchorPane = a(0)
 
Upvote 0

Patent

Member
Licensed User
Longtime User
as written, this will not work, because:
this is returning Objects (as expectetd), but only the Name of the Pane is in as a string (i.e. AnchorPane@1e97eff),
in this object there is not the pane itself (i.e. (AnchorPane) AnchorPane@1e97eff).

Error:
java.lang.ClassCastException: java.lang.String cannot be cast to javafx.scene.layout.AnchorPane
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
odd, works as expected here using this code
B4X:
...
 ' build tableview
 Dim tv As TableView
 tv.Initialize("")
 tv.SetColumns(Array("one","two"))
 tv.SetColumnWidth(0,200)
 tv.SetColumnWidth(1,200)
 ' create the panes
 Dim p,p1 As Pane
 p.Initialize("")
 p1.Initialize("")
 ' create the labels
 Dim la,la2 As Label
 la.Initialize("")
 la.Text = "test"
 la2.Initialize("")
 la2.Text = "test2"
 ' add abels to panes
 p.AddNode(la,0,0,-1,-1)
 p1.AddNode(la2,0,0,-1,-1)
 ' add panes to tableview
 tv.Items.Add(Array(p,p1))
 ' add tableview to mainform
 MainForm.RootPane.AddNode(tv,0,0,-1,-1)
 ' grab line 0 from table
 Dim a() As Object = tv.Items.Get(0)
 ' set temp pane to item 1
 Dim tp As Pane = a(1)
 ' grab label from pane
 Dim lat As Label = tp.GetNode(0)
 ' log text from label
 Log(lat.Text)
...
 
Upvote 0
Top