B4J Question Packaged project error

oldeast

Active Member
Licensed User
Longtime User
Hi, my compiled jar file runs OK but when I package it, only the splash screen runs and the project closes. I tried reversing the order of closing the splash screen and opening the 'object' form, the jar file runs ok but the packaged product won't run. The object form fills a table view with records and this all runs fine in the jar file. Is it ok to use the a splash form in this way?
Thanks for any suggestions.

B4X:
#Region  Project Attributes
    #MainFormWidth: -1
    #MainFormHeight: -1
    #AdditionalJar: lib/sqlite-jdbc-3.8.11.2

#End Region

Sub Process_Globals
    Private fx As JFX
    Private frmMain As Form

    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim ProgName As String                    : ProgName = "Collection Manager"
    Dim ProgVersion As String                : ProgVersion = "Version 0.9       05/12/2016"
    Dim Copyright As String                    :
    Dim lblName As Label               
    Dim lblVersion As Label               
    Dim lblCopyright As Label           
    End Sub

Sub AppStart (Form1 As Form, args() As String)
        frmMain=Form1
        frmMain.Initialize("frmMain", 500, 500)
        frmMain.RootPane.LoadLayout("Startup.bjl")
        frmMain.Resizable=False
        frmMain.SetFormStyle("UNDECORATED")

        lblName.Text=ProgName
        lblVersion.Text=ProgVersion
        lblCopyright.text=Copyright

        'splash screen - title screen -
         Timer1.Initialize("Timer1", 2000)
         Timer1.Enabled=True
        frmMain.Show
End Sub
Sub Timer1_tick
    ObjectForm.ShowObject
    frmMain.Close
End Sub
 
Last edited:

jmon

Well-Known Member
Licensed User
Longtime User
You can't close the MainForm (frmMain in your case). As the name says it, it's the main part of your application. Closing it will shutdown your application.

In fact, your ObjectForm should load into your mainform, and call a splash separately.

a bit like this: Code for the Main:
B4X:
Sub AppStart (Form1 As Form, args() As String)
    MainForm = Form1
    MainForm.LoadLayout("Main")
    'MainForm.show '(Do not show the mainform yet

    Dim sp As Splash 'call a class named splash
    sp.initialize(Me, "Splash")
    sp.show

End Sub

Sub Splash_Closed
     'show the mainform now
     MainForm.Show
End Sub

Code for a Class named "Splash"
B4X:
Sub Class_Globals
    Private fx As JFX
    Private t as Timer
    Private frmSplash as Form
    Private m as object
    Private sEventName as string
End Sub

Sub Initialize(Module as object, EventName as string)
    m = module
    sEventName = EventName

   'the timer will run 2 seconds
   t.initialize("t", 2000)
   t.enabled = true

    frmSplash.initialize("")
    frmSplash.loadlayout("splashLayout")
    frmSplash.show

End Sub

Sub t_tick
    'when timer ticks, close the splash form, then notify the main module
    frmSplash.close
    callSub(m, sEventName & "_Closed")
End Sub

Tell me if it's clear or not. I wrote the code from memory, it may not be accurate.
 
Upvote 0

oldeast

Active Member
Licensed User
Longtime User
Thanks I did not understand how the Main form worked in B4J as this code was a B4A project originally, I can work around your code so no problem.
Thanks so much for your assistance, much appreciated.
Graham
 
Upvote 0
Top