B4J Question nullpointer on datepicker

le_toubib

Active Member
Licensed User
Longtime User
hi all
i'm on 3.70
using this code :
Sub dp_pt_spn_dob_FocusChanged (HasFocus As Boolean)

If HasFocus = False Then
Dim date As Long
date = DateTime.DateParse(subDP3.GetDatePickerText(True))

i get this error

Error occurred on line: 288 (Main)
java.lang.NullPointerException
at b4j.example.datepicker._getdatepickertext(datepicker.java:64)
at b4j.example.main._dp_pt_spn_dob_focuschanged(main.java:3085)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:593)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:228)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:158)
at sun.reflect.GeneratedMethodAccessor11.invoke(Unknown Source)


in the line :
date = DateTime.DateParse(subDP3.GetDatePickerText(True))
what am i missing ?
 

le_toubib

Active Member
Licensed User
Longtime User
Subdp3 is a datepicker control added in the scene builder .
Very difficult to remake the whole layout from the start using the internal designer. It's huge
 
Upvote 0

rwblinn

Well-Known Member
Licensed User
Longtime User
Just for clarity based on this information.
If using B4J v4.00 the DataPicker control events as defined using the JavaFX Scene Builder are not supported anymore.

I did a test using B4J v4.00 and a DatePicker defined using the JavaFX Scene Builder. Events like DatePicker_ValueChanged (Value As Long) are not triggered anymore.

Suggest to mention in the B4J v4.00 Release Notes (and if there would be a workaround to resolve for complex FXML layouts which can not be converted).
There might be more impact examples, like using new views.
 
Last edited:
Upvote 0

le_toubib

Active Member
Licensed User
Longtime User
solved by changing the last line into :
B4X:
date = DateTime.DateParse(asJO(dp_pt_spn_dob).RunMethod("getValue",Null))

for some reason initializing the datepicker (subDP3.Initialize(dp_pt_spn_dob, False) ) in appstart was "lost" , so it s not initialized on focus change .
 
Upvote 0
Top