B4J Question [Solved] Getting error as Object Not Initialised

AndroidMadhu

Active Member
Licensed User
Hello,
I am getting error as below :
B4X:
WARNING: package com.sun.javafx.embed.swing.oldimpl not in javafx.swing
Waiting for debugger to connect...
Program started.
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
Error occurred on line: 64 (B4XMainPage)
java.lang.RuntimeException: Object should first be initialized (ComboBox).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:49)
    at anywheresoftware.b4j.objects.ComboBoxWrapper.getItems(ComboBoxWrapper.java:113)
    at b4j.example.b4xmainpage$ResumableSub_Button2_Click.resume(b4xmainpage.java:326)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:47)
    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:564)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
    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:564)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:42)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:156)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:105)

Though I have declared Combo Box.
I have attached my project for reference on which I am working upon.

Can you please suggest on this.

Thanks
 

Attachments

  • Project_Test.zip
    10.9 KB · Views: 91

Daestrum

Expert
Licensed User
Longtime User
I don't know B4XPages, but it seems like cbo2 should be defined on page_2 as the layout containing it is loaded by page_2. Just a thought.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
The problem is the following:
1. You must declare, as already advised, cbo2 in page_2.

2. You must create page_2 to make sure that cbo2 is already known.
Replace:
B4XPages.AddPage("p2",page_2)
by
B4XPages.AddPageAndCreate("p2",page_2)

3. You must refer to cbo2 in page_2.
Replace:
cbo2.Items.Add(region.Get(rlist).As(Map).Get("region"))
by
page_2.cbo2.Items.Add(region.Get(rlist).As(Map).Get("region"))

Attached your modified project.
 

Attachments

  • Project_Test.zip
    20.4 KB · Views: 99
Upvote 0
Top