I'm getting an error when using inline casting to set the parameter type for a javaobject call to jGauges.
For example, "setMinValue" & "setMaxValue" want a double. But adding to the jGauges example app:
Generates the error:
But using the following instead works successfully:
Am I doing something incorrectly with the inline casting?
For example, "setMinValue" & "setMaxValue" want a double. But adding to the jGauges example app:
B4X:
Sub AppStart (Form1 As Form, Args() As String)
:
:
:
SetMaxMin
End Sub
Private Sub SetMaxMin
Dim joGauge As JavaObject = Gauge1
Dim minVal As Float = 0
Dim maxVal As Float = 100
joGauge.RunMethod("setMinValue", Array(minVal.As(Double)))
joGauge.RunMethod("setMaxValue", Array(maxVal.As(Double)))
End Sub
Generates the error:
B4X:
java.lang.RuntimeException: Method: setMinValue not matched.
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:130)
at b4j.example.main._setmaxmin(main.java:202)
at b4j.example.main._appstart(main.java:128)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:577)
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.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:577)
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 b4j.example.main.start(main.java:38)
at javafx.graphics@18.0.1/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
at javafx.graphics@18.0.1/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:484)
at javafx.graphics@18.0.1/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics@18.0.1/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
at javafx.graphics@18.0.1/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics@18.0.1/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics@18.0.1/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
at java.base/java.lang.Thread.run(Thread.java:833)
But using the following instead works successfully:
B4X:
Private Sub SetMaxMin
Dim joGauge As JavaObject = Gauge1
Dim minVal As Float = 0
Dim maxVal As Float = 100
Dim minDouble As Double = minVal
Dim maxDouble As Double = maxVal
joGauge.RunMethod("setMinValue", Array(minDouble))
joGauge.RunMethod("setMaxValue", Array(maxDouble))
End Sub
Am I doing something incorrectly with the inline casting?