hello, this is an example for the way i know how to create a control array in b4j.
if i would'nt want a gui update during it - that's fine.
but since i do want a gui update during action - i add sleep(0)+Resumable Sub.
that slows the action from 1 sec to 7 sec (when running the executable created by 'build standalone package') on the test laptop.
is there a way to speed up this code ?
if i would'nt want a gui update during it - that's fine.
but since i do want a gui update during action - i add sleep(0)+Resumable Sub.
that slows the action from 1 sec to 7 sec (when running the executable created by 'build standalone package') on the test laptop.
is there a way to speed up this code ?
B4X:
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private offsetX As Double
Private offsetY As Double
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1")
maximizeMainForm
MainForm.Show
offsetX=MainForm.Width/2000/1.5
offsetY=MainForm.Height/2000/1.5
End Sub
Private Sub maximizeMainForm
Dim mf As JavaObject = MainForm
mf.GetFieldJO("stage").RunMethod("setMaximized", Array(True))
End Sub
Sub MainForm_MouseClicked (EventData As MouseEvent)
Wait For (loadControlArray) Complete (result As String)
End Sub
Private Sub loadControlArray As ResumableSub
Dim t0 As Long
t0=DateTime.Now
Dim i As Int
Dim x As Double
Dim y As Double
x=1
y=1
For i=1 To 2000
Dim lbl As Label
lbl.Initialize("lbl")
lbl.Text="X"
lbl.Tag=i
MainForm.RootPane.AddNode(lbl,x,y,10dip,10dip)
x=x+offsetX
y=y+offsetY
Sleep(0)
Next
fx.Msgbox(MainForm, NumberFormat((DateTime.Now-t0)/1000,0,0) & " seconds.","")
Return Null
End Sub