B4J Question Error to do with rootpane, mainpain and other panes [Solved]

Peter Lewis

Active Member
Licensed User
Longtime User
Hi All

I think my understanding of the panes could be the problem

Please can someone explain it to me when I am going wrong

I have an app with my main code module

B4X:
    MainForm = Form1
    MainForm.RootPane.LoadLayout("RootLayout") 'Load the layout file.

then I got another Code module called playgame

in Sub Start:
    Main.RootPane.RemoveAllNodes
    Main.RootPane.LoadLayout("playgame") 'Load the layout file

Up to this point every thing works well

When I want to change the colour of one of the buttons in the layout

B4X:
form.Stylesheets.Add(File.GetUri(File.DirAssets, "RedButton.css"))
    form.Show

I get an error on the first line
What is the best selling album of all time from 1976 to 2018?
1
4
2
3
Error occurred on line: 88 (PLAYGAME)
java.lang.NullPointerException
at anywheresoftware.b4j.objects.Form.getStylesheets(Form.java:292)
at b4j.quiz.playgame._getquestion(playgame.java:245)
at b4j.quiz.playgame._start(playgame.java:80)
at b4j.quiz.joingame._timer2_tick(joingame.java:774)
at jdk.internal.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
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:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at jdk.internal.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
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:91)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.objects.Timer$TickTack$1.run(Timer.java:118)
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)

Thank you
 

Peter Lewis

Active Member
Licensed User
Longtime User
I made that variable the same at the Form name of the root of the designer , but the SwiftButtons work perfectly

1586782418598.png


I thought it was a form as it said Form title , MyBad
 
Upvote 0
Top