B4J Question multiple istances of same form

cirollo

Active Member
Licensed User
Hi to everyone!

After using B4A and B4I I've decided to start using B4J for my desktop app.

My question is:

how can I open the same form more than one time (for example calling it from a menu)?

Windows behaviour on my VFP app let me to open the same form (for example, invoices) more than one time and to minimize/maximize them or passing from one to another by clicking the form itself.

is possible in B4j?

regards,

Ciro
 

Erel

Administrator
Staff member
Licensed User
Create a class named MyForm with this code:
B4X:
Sub Class_Globals
   Private fx As JFX
   Private form1 As Form
End Sub

Public Sub Initialize
   form1.Initialize("form1", 500, 500)
   form1.Title = "form1"
End Sub

Public Sub Show
   form1.Show
End Sub
In your main module put this code:
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
   For i = 1 To 5
     Dim mf As MyForm
     mf.Initialize
     mf.Show
   Next
End Sub
Run it and you will see one main form and 5 MyForms.
 
Top