B4J Question Anchor object at runtime

micro

Well-Known Member
Licensed User
Longtime User
Hi to all
How I can anchor from code, objects created at runtime?
In Java Fx Scene is simple in Layout < AnchorPane Constraints>, but do not know how to code.
Thanks
 

Attachments

  • Anchor.jpg
    Anchor.jpg
    11.1 KB · Views: 306

micro

Well-Known Member
Licensed User
Longtime User
OK is simple
Anchor at the center of the screen

B4X:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Dim lsv As ListView
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    lsv.Initialize("lsv")
    MainForm.RootPane.LoadLayout("lay1") 'Load the layout file.
    MainForm.RootPane.AddNode(lsv, 0, 0, 100, 100)
    lsv.Items.Add("Hello")
    MainForm.Show
    MainForm.RootPane.SetAnchors(lsv, (MainForm.Width/2)- lsv.Width, (MainForm.Height/2) - lsv.Height, (MainForm.Width/2) - lsv.Width, (MainForm.Height/2) - lsv.Height)
End Sub
 
Upvote 0
Top