B4J Question Questions about dynamically create Nodes

rdkartono

Member
Licensed User
Longtime User
I want to fill a Pane with dynamically created Checkboxes. I read this tutorial about Nodes however not clear enough.

So inside a form, there is a GridPane to split screen become Top, Middle and Bottom part (did that nicely).
In midle part, there is AnchorPane (obviously), and inside it there is Accordion.
In this Accordion, i want to dynamically create TitledPanes (for grouping checkboxes), and inside it, I want to insert a GridPane again (to make checkboxes arranged beautifully), and then a checkbox inside each cells.

Also I want to know how to gather checked checkboxes from software. Seems my experiences on VB .NET is not same in this case.

Any example on doing it ? I think I supposedly do it by Node property, however no example found to make clear understanding.

Hopefully B4J masters can help me.

Regards,

Rudy Darmawan.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Leave the GridPane for now. It makes the solution more complicated.

SS-2014-09-22_09.26.26.png

B4X:
Sub Process_Globals
   Private fx As JFX
   Private MainForm As Form
End Sub

Sub AppStart (Form1 As Form, Args() As String)
   MainForm = Form1
   MainForm.Show
   CreateCheckboxes(MainForm.RootPane, 5, 6)
End Sub

Sub CreateCheckboxes(Parent As AnchorPane, NumX As Int, NumY As Int) As CheckBox(,)
   Dim width As Int = Parent.width / NumX
   Dim height As Int = Parent.height / NumY
   Dim cb(NumX, NumY) As CheckBox
   For x = 0 To NumX - 1
     For y = 0 To NumY - 2
       Dim chk As CheckBox
       chk.Initialize("chk")
       Parent.AddNode(chk, 20 + x * width, y * height, width - 5, height - 5)
       chk.Text = "Checkbox (" & x & "," & y & ")"
       cb(x, y) = chk
     Next
   Next
   Return cb
End Sub

Sub chk_CheckedChange(Checked As Boolean)
   Dim chk As CheckBox = Sender
   Log(chk.Text & ": " & Checked)
End Sub
 
Upvote 0

rdkartono

Member
Licensed User
Longtime User
Hi Erel ,

Thank you for the example. I can understand your example.
However on Accordion, no such "AddNode" function. Just "Node" property, which we can GET or SET. Any advice ?
 
Upvote 0
Top