B4J Question AnotherDatePicker in a TabPane?

AKJammer

Member
Licensed User
I keep getting a Null Pointer Exception when attempting to use AnotherDatePicker in a TabPane.

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Public Sub Show

If frm.IsInitialized = False Then
frm.Initialize("Events", 800, 600)
frm.RootPane.LoadLayout("Events") 'Load the layout file
End If
frm.Show

findEvents(cbShow.Checked)

tpNew = tabEventDtls.LoadLayout("tabNew", "New Event")
tpDance = tabEventDtls.LoadLayout("tabDance", "Dance Event")
tpCruise = tabEventDtls.LoadLayout("tabCruise", "Cruise")
tpTrain = tabEventDtls.LoadLayout("tabTrain", "Train")
tpOther = tabEventDtls.LoadLayout("tabOther", "Other")

End Sub

VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
Public Sub DesignerCreateView (Base As Object, Lbl As Label, Props As Map)
mBase = Base
Dim mlbl As B4XView = Lbl
#if B4J
Dim form As Form = Props.Get("Form")
MainPanel = form.RootPane
Dim df As TextField
df.Initialize("DateField")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The error says it's here when it tries to assign MainPanel. In debug, Props has data, but form shows up as null after assignment, so somethings not right.

DatePicker works fine, but can't get AnotherDatePicker to work.



Any ideas?
 

AKJammer

Member
Licensed User
1. Will do. Sorry about that.
2. I tried to cut and paste from the logs, but it wouldn't let me select it. If you say I can, then I'll have to poke around a bit more to find where I can get it.
3. So I don't have to include the AnotherDatePicker.bas file? I'll pull it out and just include the XUI library.

Thanks,
Jim
 
Upvote 0

AKJammer

Member
Licensed User
I added AnotherDatePicker to a regular dialog form and it works just fine, but when I added it to a TabPane I get the below exception. Does anyone have an example of it working in a B4J tabpane?

Waiting for debugger to connect...
Program started.
Not Set
Event Registration Environment variable 'MMRegDBDir' Not set. Using local database.
opened database successfully
3
2019 Mountain Magic
Dance
2019-10-10 00:00:00
Clicked Events
Error occurred on line: 60 (AnotherDatePicker)
java.lang.NullPointerException
at b4j.example.anotherdatepicker$ResumableSub_DesignerCreateView.resume(anotherdatepicker.java:766)
at b4j.example.anotherdatepicker._designercreateview(anotherdatepicker.java:712)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4j.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:62)
at anywheresoftware.b4j.objects.LayoutBuilder.loadLayout(LayoutBuilder.java:93)
at anywheresoftware.b4j.objects.PaneWrapper.LoadLayout(PaneWrapper.java:84)
at anywheresoftware.b4j.objects.TabPaneWrapper.LoadLayout(TabPaneWrapper.java:94)
at b4j.example.eventform._show(eventform.java:165)
at b4j.example.mainmenu._btnevents_click(mainmenu.java:93)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA$1.run(BA.java:216)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)
 
Upvote 0

AKJammer

Member
Licensed User
Hmmm. I'm using B4J 7.0 and the AnotherTabPicker.bas version shows 7.3, that's the latest one I could find. What version am I behind on and I'll update it.

Here's a sample project showing the error.
 

Attachments

  • PickerInTab.zip
    12.3 KB · Views: 88
Upvote 0

Daestrum

Well-Known Member
Licensed User
I can see why it doesn't work (the form doesn't get passed to the DesignerCreateView), but can't find an elegant solution, just a hacky one for your case.

in AnotherDatePicker add
B4X:
...
#if B4J
 If Props.ContainsKey("Form") Then        '  new line
  Dim form As Form = Props.Get("Form") ' existing line
 Else                              ' new line
  Dim form As Form = CallSub(CallBack,"getForm") ' new line
 End If ' new line
 MainPanel = form.rootpane                    'existing line
...

in TabCode add
B4X:
Sub getForm As Form
       return frm
End Sub

Also as a suggestion, put the tabpane1.loadlayout in the if block in TabCode, or else it just keeps adding tabs every time you re-open the window from the button.
 
Last edited:
Upvote 0

AKJammer

Member
Licensed User
Sweet!! Thanks. Glad to have found a bug. LOL, yeah, never got to the point where I could see the tab panes expanding. Got them moved. Thanks again.
 
Upvote 0
Top