B4J Question Slider -> JavaObject RunMethod

bembulak

Member
Licensed User
Hi!

I have an application that has several sliders. Each has the following values (can be set in Designer):
Min: 1
Max: 3
StartingValue: 2

When I ran my code, the first thing I saw was, that the 'knob' is not sticky. You can move it back and forth and JavaFx returns Double-Values.
After searching the forums I've found a great answer: Things that are not provided natively in B4J can be achieved via "JavaObject"-Lib and RunMethod (Thanks to Klaus!).

I played a little with the options found at the original documentation site: http://docs.oracle.com/javafx/2/api/javafx/scene/control/Slider.html

Unfortunately though, I can't get my code to work. It fails for one particular Method: setMinorTickCount

I could not belive, that B4J is wrong (and still can't), so I've built a little "native" Java program, based on the official Java-Tutorial for the Slider (MinimalSlider_02).
There the method works. In B4J it still fails with the following error:
B4X:
Waiting for debugger to connect...
Program started.
Error occurred on line: 28 (Main)
java.lang.RuntimeException: Field: setMinorTickCount not found in: javafx.scene.control.Slider
    at anywheresoftware.b4j.object.JavaObject$FieldCache.getField(JavaObject.java:306)
    at anywheresoftware.b4j.object.JavaObject.SetField(JavaObject.java:173)
    at b4j.example.main._appstart(main.java:105)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:612)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:229)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
    at b4j.example.main.start(main.java:38)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
    at java.lang.Thread.run(Thread.java:745)

Has anybody an idea? I've attached my tests/samples. Any hint is highly appreciated. Thank you!
 

Attachments

  • MinimalSlider_02.zip
    2.1 KB · Views: 295
  • slider_exampleB4J.zip
    2.1 KB · Views: 243

stevel05

Expert
Licensed User
Longtime User
Strange, the error I got was : java.lang.RuntimeException: Method: setMinorTickCount not matched.

This is because you are passing 0.0 which is converted to a Double. In the documentation setMinorTickCount requires an Int.

Replaced it with 0 (An Int) and it works.

If you are still getting the not Found error, what version of the JDK have you installed?
 
Upvote 0
Top