B4J Question BBScrollingLabel customview crash

inakigarm

Well-Known Member
Licensed User
Longtime User
Hi:

I'm trying to test the BBScrollingLabel Customview and when I create a layout with the BBScrolling Label, and run the app crash with this error (the layout has one Button, on BBLabel and one BBscrollLabel; BBLabel works fine when deleting the BBScrollingLabel form layout and the project references)
Waiting for debugger to connect...
Program started.
Ha ocurrido un error en la línea: 63 (BBLabel)
java.lang.NullPointerException
at b4j.example.bblabel._settextengine(bblabel.java:64)
at b4j.example.bbscrollinglabel._setshared(bbscrollinglabel.java:503)
at b4j.example.bbscrollinglabel$ResumableSub_DesignerCreateView.resume(bbscrollinglabel.java:482)
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: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.raiseEvent(BA.java:78)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:42)
at anywheresoftware.b4a.keywords.Common$2$1.run(Common.java:1018)
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)


These are the libs of the project (on B4J 8.50 and jdk-11.0.1)



I've spend one hour trying to understand the problem of this simple project; anybody has test this Customview on B4J ?
 

Attachments

  • provascrollinlabelUI.zip
    3.4 KB · Views: 211

Erel

B4X founder
Staff member
Licensed User
Longtime User
It happens because of the unneeded Sleep call.

You must set the text engine right after the layout is loaded. You should also set the text (this is something that should be fixed in the library, it should have handled empty text).
B4X:
MainForm.RootPane.LoadLayout("MainPage")
Textengine1.Initialize(MainForm.RootPane)    
BBScrollingLabel2.TextEngine = Textengine1
BBScrollingLabel2.Text = "test"
 
Upvote 0

inakigarm

Well-Known Member
Licensed User
Longtime User
You must set the text engine right after the layout is loaded. You should also set the text (this is something that should be fixed in the library, it should have handled empty text).

Thanks, found it. (the sleep addition was trying to find a solution but seems not the problem..)

If there's no text assingment in BBScrollingLabel2 in AppStart
B4X:
BBScrollingLabel2.Text = "test"
, the app crash

Waiting for debugger to connect...
Program started.
Ha ocurrido un error en la línea: 110 (BBScrollingLabel)
java.lang.RuntimeException: Object should first be initialized (Image).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:32)
at b4j.example.bbscrollinglabel._getbitmap(bbscrollinglabel.java:365)
at b4j.example.bbscrollinglabel$ResumableSub_AfterTextOrSizeChanged.resume(bbscrollinglabel.java:140)
at b4j.example.bbscrollinglabel._aftertextorsizechanged(bbscrollinglabel.java:91)
at b4j.example.bbscrollinglabel._setshared(bbscrollinglabel.java:543)
at b4j.example.bbscrollinglabel$ResumableSub_DesignerCreateView.resume(bbscrollinglabel.java:516)
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: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.raiseEvent(BA.java:78)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:42)
at anywheresoftware.b4a.keywords.Common$2$1.run(Common.java:1018)
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)


The solution is assign a text in AppStart (I thought that this was ammended).
A bit strange that it should have a text assingment in AppStart (tried to assign a "" or " " but didn't work); I'll have to play with View's visibility for not displaying initial text (but this property doesn't exist on BBScrollingLabel view, and must create a Parent panel to hide the view)

Adding this to the b4xlib code does the job
B4X:
Public Sub setVisible(Visible As Boolean)
    mBase.Visible = Visible
End Sub

Public Sub getVisible As Boolean
    Return mBase.Visible
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…