when adding buttons to a pane using code below, the Buttons Width and Height are fixed and not set acoording the code.
Is this a bug or do I miss something in the code?
B4X:
Sub CreateCharMatrix
Dim btn As Button
btn.Initialize("btn")
btn.Tag = "1"
MainForm.RootPane.AddNode(btn, 20, 20, 10, 10)
Dim btn As Button
btn.Initialize("btn")
btn.Tag = "2"
MainForm.RootPane.AddNode(btn, 20, 80, 20, 20)
End Sub
It seems that JavaFX nodes have a minimum size. I had a similar issue with TextArea.
Also note that, adding the node to the parent pane sets it to the "preferred" values of Height and Width, which can be different from the Height/Width intended
Thanks all for your hints.
Tried several solutions, but ended up, after the node has been created, using the API call setMinSize as @BeneBarros suggested.
B4X:
'define the button and add to the rootpane of the mainform
Dim btn As Button
btn.Initialize("btn")
btn.Text = "Button 1"
'h and w must have initial value > 0
MainForm.RootPane.AddNode(btn, 20,20, 1, 1)
Dim jo As JavaObject = btn
Dim h As Double = 15.0
Dim w As Double = 15.0
jo.RunMethod("setMinSize", Array(h, w))
BTW: Look here if you want to know why I had asked.