B4J Question TitledPane Text Change

coyote

Member
Licensed User
Longtime User
Hello,

is it possible to change the text for "TitledPane"?

I've tried:
B4X:
 Private tp1 As Node
setTitledPaneText(tp1, "xyz")

Sub setTitledPaneText(TP As Node, Text As String )
  Dim jo As JavaObject = TP
  jo.RunMethod("setText", Text)
End Sub

But failed:
jo.RunMethod("setText", Text)

B4X:
java.lang.IllegalArgumentException: argument type mismatch
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:504)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:215)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:153)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:69)
    at anywheresoftware.b4a.BA$2.run(BA.java:162)
    at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:182)
    at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:179)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:17)
    at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:67)
    at java.lang.Thread.run(Thread.java:744)


Any help are welcome.

Coyote
 

rwblinn

Well-Known Member
Licensed User
Longtime User
Hi,

use Array As Object to set the text:

B4X:
Sub setTitledPaneText(TP As Node, Text As String )
  Dim jo As JavaObject = TP
  jo.RunMethod("setText", Array As Object(Text))
End Sub
 
Upvote 0

coyote

Member
Licensed User
Longtime User
Hi and thank you, it works.
But I have to do a refresh or resize, after that the text appears.

How can I do a refresh like mainform.refresh?

Thx, Coyote
 
Upvote 0

rwblinn

Well-Known Member
Licensed User
Longtime User
Hi,

refresh I do not know, but resize via

Sub setTitledPaneWidth(TitledPane As Node, nW As Double)
Dim jo As JavaObject = TitledPane
jo.RunMethod("setPrefWidth", Array As Object(nW))
End Sub

May be others know better solutions.
 
Upvote 0

coyote

Member
Licensed User
Longtime User
Hi,

next day, new ideas and it works.
There was something wrong in my Scene Builder.
I deleted all my stuff and build the form again. After that the text is changing immediately without any resizing.

Thx again, Coyote
 
Upvote 0
Top