B4J Question form close error

JTmartins

Active Member
Licensed User
Longtime User
I have 2 pieces of code.

in Main I call a modal dialog as

B4X:
Sub mnuViaturasNova_Action
    Dim mf As ModalForm
    mf.Initialize(MainForm,"frmViaturasNovo","UTILITY","Nova Viatura")
    MainForm.BackColor = mf.Show
End Sub

the modal window with the form comes up

The second piece of code is

B4X:
'Class module
Sub Class_Globals
    Private fx As JFX
    Private frm As Form
  
    Private ancoraNovaViatura As AnchorPane
    Private pnlCRUD As Pane
    Private btnCancelarNovaViatura As Button
    Private btnLimparNovaViatura As Button
    Private btnGravarNovaViatura As Button
    Private edtMatricula As TextField
    Private lblMatricula As Label
    Private lblMarca As Label
    Private dropMarca As ComboBox
    Private lblcombustivel As Label
    Private dropCombustivel As ComboBox
    Private lblStatus As Label
    Private dropStatus As ComboBox
    Private lblClasse As Label
    Private dropClasse As ComboBox
    Private lblTitulo As Label
    Private imvIconeCarro As ImageView
    Private progressGravar As ProgressIndicator
  
  
End Sub

Public Sub Initialize (Parent As Form,layout As String,estilo As String,titulo As String)
    frm.Initialize("frm", 600dip, 300dip)
    frm.Title = titulo
    frm.SetFormStyle(estilo)
    frm.RootPane.LoadLayout(layout)
    frm.SetOwner(Parent)

  
End Sub



Public Sub Show As Paint
    frm.ShowAndWait

End Sub

Sub frm_CloseRequest (EventData As Event)
    frm.Close
End Sub

Sub btnCancelarNovaViatura_Action
    frm.Close
End Sub

I must be doing something wrong in the way I'm calling as when clicking the btnCancelarNovaViatura button or close the modal form in the X i get a java error coming from MAIN.


main._mnuviaturasnova_action (java line: 314)
java.lang.NullPointerException
at GesdriverBO.com.main._mnuviaturasnova_action(main.java:314)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.BA$2.run(BA.java:162)
at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:182)
at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:179)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:17)
at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:67)
at java.lang.Thread.run(Thread.java:744)

If someone can guide me, I would appreciate.
many thanks
 

JTmartins

Active Member
Licensed User
Longtime User
Can I send it over email ? if so where to ?

There is also a test login thing here, with an address to a sql server, which I would not like to be public.
 
Upvote 0

JTmartins

Active Member
Licensed User
Longtime User
Ok. I've made a reproduction. When run, login is "test" in all 3 fields.

Then click in Viaturas Menu option and then Nova Viatura.

The modal comes up, then use button "cancelar" to close. (I took out the frm.close in the closeRequest)

Many thanks
 

Attachments

  • ErrorOnFormClose.zip
    45.5 KB · Views: 226
Upvote 0

JTmartins

Active Member
Licensed User
Longtime User
obvious...lol. stupid me

yes, this code was from color picker, I'm trying to understand how to play with forms.

thanks
 
Upvote 0
Top