How do I programatically add a button to a scrollpane rather than to the rootpane? I've dragged a scrollpane onto the layout, given it an id of sp1. I can use addnode to add a button to the main anchorpane but don't know how add a node to the scrollpane instead.
Thank you. For now it is not possible to use ScrollPane. It will be supported in the next update. Note that the items should be added to the internal AnchorPane (though it will not work).
You can consider using ListView instead. See this tutorial: Customized ListView
I am trying to add controls to a scrollpane, but there doesn't seem to be an option to add to the innernode. See attached program. I want to add the time spinners to the scroll pane.
sorry erel but your answer there is not clear enough (at least for me).
i have created in designer a pane and i would like to add it to the scrollpane but i get an error.
B4X:
Dim p As Pane
p.Initialize("")
p = leftscrollp.InnerNode
p.AddNode(menupnl,0,0,leftscrollp.Width,leftscrollp.Height)
Program started.
Error occurred on line: 22 (main).
java.lang.RuntimeException: Object should first be initialized (Node).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:32)
at b4j.example.main._appstart(main.java:91)
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:497)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:563)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:224)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:156)
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:497)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:82)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at b4j.example.main.start(main.java:36)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$159(LauncherImpl.java:863)
at com.sun.javafx.application.LauncherImpl$$Lambda$53/2114892413.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$172(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl$$Lambda$46/237061348.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImpl.java:295)
at com.sun.javafx.application.PlatformImpl$$Lambda$48/1704355536.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(PlatformImpl.java:294)
at com.sun.javafx.application.PlatformImpl$$Lambda$47/1030870354.run(Unknown Source)
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$145(WinApplication.java:101)
at com.sun.glass.ui.win.WinApplication$$Lambda$36/1232367853.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
ok i solved it in a different way, just created a layout with only that pane and i am loading the layout to the scrollpane, but still i would like to know how i can make it without creating a new layout...
The code you posted is wrong. You initialize a pane and then you set the non-existent pane from ScrollPane.InnerNode to the same variable.
You should instead set InnerNode: