B4J Question Application Flow

JaunLukePicard

Member
Licensed User
Longtime User
I want to get back into B4A and saw the new B4J developement environment. It looks very promissing.

I am designing an application that will support both Desktop and portable needs. This application would have several Forms and Classes. I am grouping them by function in VisualBasic. For instance. I have a Splash Screen and then the Main Form. The Main form has a class 'clsMain" associated with it.

When the Spash Screen is closed the application launches the Main class which opens the Main Form. Can I do this same type of thing with B4J? Do you have an example?

I use this setup to make it easier to reference code for Forms easier to maintain throughout the application life-cycle. This way unless I have clearly made a Module or Class that has Subs for Functions for multiple Forms/functions the class is specific for set of related Forms.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can create applications with any number of forms in B4J.

Forms are regular objects like any other object. This means that you can create a class for each form or create one class that handles many forms (or module).

Here is the code of a simple program with a splash screen:
B4X:
'Main module
Sub Process_Globals
   Private fx As JFX
   Private MainForm As Form
   Private t As Timer
End Sub

Sub AppStart (Form1 As Form, Args() As String)
   MainForm = Form1
   MainForm.SetFormStyle("UNDECORATED")
   MainForm.RootPane.Style = "-fx-background-color: blue;"
   MainForm.Show
   t.Initialize("t", 3000)
   t.Enabled = True
End Sub

Sub t_Tick
   t.Enabled = False
   Dim f As Form2
   f.Initialize
   f.Show
   MainForm.Close
End Sub

B4X:
'Form2 class
Sub Class_Globals
   Private fx As JFX
   Private frm As Form
End Sub

Public Sub Initialize
   frm.Initialize("frm", 500, 500)
End Sub

Public Sub Show
   frm.Show
End Sub
 
Upvote 0

JaunLukePicard

Member
Licensed User
Longtime User
Thank You Erel Got it.

So as with B4A B4J needs to declare a variable and then initialize the class, module, Form, control, etc. In B4A we use Activities, but those are "Forms" in B4J?
 
Upvote 0

tcgoh

Active Member
Licensed User
Longtime User
Hi,
I'm trying to add a splash screen for my completed project with only 1 main coded module. With your example above the first splash screen have to be the main module.
How do I move my completed coded module to "Form2 class" ?

Thanks
 
Upvote 0
Top