B4J Question B4XFloatTextField.TextField.SetTextAlignment error in B4J

YPMN

Member
Licensed User
Hi,
in b4j this command causes boot to fail
B4X:
B4X:
FtUser.TextField.SetTextAlignment("CENTER","CENTER")
FtUser is B4XFloatTextField.
How to solve this problem?

------------------------------------------------------------------------------------------

Waiting for debugger to connect...
Program started.
Error occurred on line: 33 (B4XMainPage)
java.lang.reflect.InvocationTargetException
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.keywords.Common.CallSubDebug2(Common.java:482)
at zns.sseambase.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:867)
at zns.sseambase.b4xpagesmanager._showpage(b4xpagesmanager.java:346)
at zns.sseambase.b4xpagesmanager._addpage(b4xpagesmanager.java:175)
at zns.sseambase.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:189)
at zns.sseambase.b4xpagesmanager._initialize(b4xpagesmanager.java:125)
at zns.sseambase.main._appstart(main.java:85)
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: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.NativeMethodAccessorImpl.invoke0(Native Method)
 

YPMN

Member
Licensed User
Ok!
here is an example of a project explaining the problem
 

Attachments

  • Test_B4XFloatTextField.zip
    3.3 KB · Views: 29
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Full error message:

java.lang.reflect.InvocationTargetException
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.keywords.Common.CallSubDebug2(Common.java:487)
at b4j.example.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:867)
at b4j.example.b4xpagesmanager._showpage(b4xpagesmanager.java:346)
at b4j.example.b4xpagesmanager._addpage(b4xpagesmanager.java:175)
at b4j.example.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:189)
at b4j.example.b4xpagesmanager._initialize(b4xpagesmanager.java:125)
at b4j.example.main._appstart(main.java:85)
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: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.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:111)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
at b4j.example.main.start(main.java:38)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
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)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:134)
at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:81)
... 35 more
Caused by: java.lang.reflect.InvocationTargetException
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.debug.Debug.CallSub4(Debug.java:115)
... 36 more
Caused by: java.lang.RuntimeException: Type does not match (class javafx.scene.control.TextField)
at anywheresoftware.b4a.objects.B4XViewWrapper.typeDoesNotMatch(B4XViewWrapper.java:573)
at anywheresoftware.b4a.objects.B4XViewWrapper.SetTextAlignment(B4XViewWrapper.java:448)
at b4j.example.b4xmainpage._b4xpage_created(b4xmainpage.java:58)
... 41 more

B4XFloatTextField.TextField will return a TextField or TextArea views. Both do not support SetTextAlignment: https://www.b4x.com/android/forum/t...ettextalignment-with-error.121863/post-762025


You can use this code instead:
B4X:
    FtUser.TextField.As(JavaObject).RunMethod("setAlignment", Array("CENTER"))
 
Upvote 0

YPMN

Member
Licensed User
Thank you very much for your answer; but unfortunately the problem persists.
Here is my config path: "C:\java\jdk-11.0.1\bin\javac.exe"; I can have a problem with my jdk version?
 
Upvote 0

YPMN

Member
Licensed User
thank you very much, it works now. I was making the following error:

B4X:
FtUser.TextField.As(JavaObject).RunMethod("setAlignment", Array("CENTER"))
B4X:
Root.LoadLayout("MainPage")

I fixed it :

B4X:
Root.LoadLayout("MainPage")
B4X:
FtUser.TextField.As(JavaObject).RunMethod("setAlignment", Array("CENTER"))

It works,
thank you very much for your assistance!
 
Upvote 0
Top