B4J Question Error java.RuntimeException

Guenter Becker

Active Member
Licensed User
Hi,
I have a B4J 10.30 project with a Main Form Style Decorated.
In my AppStart I use this code:
Java code:
Dim jo As JavaObject = MainForm
        Dim e As Object = jo.CreateEventFromUI("javafx.event.EventHandler", "scroll", Null)
        jo.RunMethod("setOnScroll", Array(e))
If I start the code at the first time after starting B4J Suite there is no error.
If I'm starting the code next time again without doing any changes I get this error:
Error message:
Waiting for debugger to connect...
Program started.
(RuntimeException) java.lang.RuntimeException: Method: setOnScroll not found in: anywheresoftware.b4j.objects.Form
(RuntimeException) java.lang.RuntimeException: Method: setOnScroll not found in: anywheresoftware.b4j.objects.Form

I' do not know why because the form is presented and working fine.

Any Idea about the reason of the error and how to avoid it?
 

stevel05

Expert
Licensed User
Longtime User
Strange, I get the error straight after starting and loading.
The Form object is B4j's implementation of the JavaFX Stage, which doesn't support setOnScroll.

What you can do is add the scroll listener on the RootPane.

B4X:
Dim jo As JavaObject = MainForm.RootPane
Dim e As Object = jo.CreateEventFromUI("javafx.event.EventHandler", "scroll", Null)
jo.RunMethod("setOnScroll", Array(e))
 
Last edited:
Upvote 0

Guenter Becker

Active Member
Licensed User
Thank you, that solved it. Sometimes it's hard to be stupid.
 
Upvote 0
Top