Edit: The solution that worked for me is in a post below below but I also want to apologize, the following line of code was somehow omitted from the MeasureText function below.
I just updated from 8 to 11 and am getting the following error:
On this line:
In this module:
TB.InitializeStatic("javafx.scene.text.TextBuilder")
I just updated from 8 to 11 and am getting the following error:
B4X:
Waiting for debugger to connect...
Program started.
Unsched Ops: 0.271 Seconds 257 Records
Error occurred on line: 17
java.lang.RuntimeException: Object should first be initialized (JavaObject).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:32)
at anywheresoftware.b4j.object.JavaObject.getCurrentClass(JavaObject.java:259)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:119)
at anywheresoftware.b4j.object.JavaObject.RunMethodJO(JavaObject.java:139)
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:234)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at jdk.internal.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
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$RemoteResumableSub.resume(DebugResumableSub.java:21)
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)
Bounds = TB.RunMethodJO("create",Null).RunMethodJO("text",Array(Text)).RunMethodJO("font",Array(TFont)).RunMethodJO("build",Null).RunMethodJO("getLayoutBounds",Null)
In this module:
B4X:
Sub MeasureText(Text As String,TFont As Font) As TextMetric
Dim TB, Bounds As JavaObject
Dim TM As TextMetric
Bounds = TB.RunMethodJO("create",Null).RunMethodJO("text",Array(Text)).RunMethodJO("font",Array(TFont)).RunMethodJO("build",Null).RunMethodJO("getLayoutBounds",Null)
TM.Width = Bounds.RunMethod("getWidth",Null)
TM.Height = Bounds.RunMethod("getHeight",Null)
Return TM
End Sub
Last edited: