B4J Question Adding node to scrollpane

Big JR

Member
Licensed User
Longtime User
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.
 
You should just call ScrollPane1.AddNode(...)

You will need to change the variable type to Pane as ScrollPane will not be recognized.

I'm getting errors.

In process globals I have:

Dim Scrollpane1 As Pane


In the action for a button outside the scrollpane I have:

Dim ThisBtn As Button

ThisBtn.Initialize("ThisBtn")

ThisBtn.Tag = "2"

ThisBtn.Text = "Play #1"

Scrollpane1.AddNode(ThisBtn, 10, 10, 60, 40)
 
Upvote 0
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.

Any ideas?
 

Attachments

Upvote 0

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.

Code: Copy
    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)

what am i doing wrong?
 
Upvote 0
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.

Code: Copy
    Dim p As Pane
    p.Initialize("")
    p = leftscrollp.InnerNode
    p.AddNode(menupnl,0,0,leftscrollp.Width,leftscrollp.Height)



what am i doing wrong?
menupn1.initialize("")
 
Upvote 0
such a simple think but cannot find anywhere in the forum a solution...

just want to add a complete pane to the scrollpane and scroll vertical... :(
 
Upvote 0
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...
 
Upvote 0
Upvote 0
Sorry but you wrote in the link you posted to do it like this.. maybe i understood it wrong

Ok i will try, thank you erel
 
Last edited:
Upvote 0
Back
Top