B4J Question Changes to Layout In Designer Results in revised layout throwing error

rgarnett1955

Active Member
Licensed User
Longtime User
Hi,

I am loading a layout as part of a custom view.

Create Item for custom list view:
'======================================================================================
Private Sub CreateCurveListItem(cv As curveSetupRec_t) As Pane
    Dim p As AnchorPane
    p.Initialize("")
    'p.LoadLayout("cvCurveSetups - Copy.bjl") ' <===='  Error here
    p.LoadLayout("cvCurveSetups.bjl") ' <===='  This work fine
    p.SetSize(1000, 64)
   
   
    setLineWidthSpinner(spinLineWidth)

    lblCurveID.Text             = cv.curveID
    lblCurveID.Tag                 = "curveID"
    lblCurveNo.Text             = cv.curveNo
    lblCurveNo.Tag                 = "curveNo"
    txtYMax.Text                 = cv.maxVal
    txtYMax.Tag                 = "maxVal"
    txtYMin.text                 = cv.minVal
    txtYMin.Tag                 = "minVal"
    cPickCurve.SelectedColor     = fx.Colors.From32Bit(cv.curveColor)
    cPickCurve.Tag                 = "curveColor"
    txtCurveName.Text             = cv.curveName
    txtCurveName.Tag             = "curveName"
    txtYUnits.text                 = cv.curveUnits
    txtYUnits.Tag                 = "curveUnits"
    spinLineWidth.SelectedIndex    = spinLineWidthMap.Get(cv.curveLineWidth)
    spinLineWidth.Tag            = "curveLineWidth"
    cbInitialDisplay.Checked     = cv.initialDisplay
    cbInitialDisplay.Tag         = "initialDisplay"
    cbPlotCurve.Checked            = cv.initialDisplay
    cbPlotCurve.Tag                = "cbPlotCurve"
    cbYAnnotations.Checked         = cv.yAxisAnotations
    cbYAnnotations.Tag             = "yAxisAnotations"

'    Log("Curve No: " & cv.curveNo  & "  cbPlotCurve.Checked  " &  cbPlotCurve.Checked &  "  cbYAnnotations: "  & cbYAnnotations.Checked)
    Return p
End Sub

It was working fine until I made rearrangements of the views within the layout. After I did this I received the following error:

Error On Load Layout:
java.lang.RuntimeException: JSON Array expected.
    at anywheresoftware.b4j.objects.collections.JSONParser.NextArray(JSONParser.java:62)
    at anywheresoftware.b4j.objects.MenuItemWrapper$MenuBarWrapper.parseMenusJson(MenuItemWrapper.java:276)
    at anywheresoftware.b4j.objects.NodeWrapper$ControlWrapper.build(NodeWrapper.java:1038)
    at anywheresoftware.b4j.objects.LabeledWrapper.build(LabeledWrapper.java:105)
    at anywheresoftware.b4j.objects.CheckboxWrapper.build(CheckboxWrapper.java:71)
    at jdk.internal.reflect.GeneratedMethodAccessor23.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.DynamicBuilder.build(DynamicBuilder.java:16)
    at anywheresoftware.b4j.objects.LayoutBuilder.loadLayoutHeader(LayoutBuilder.java:142)
    at anywheresoftware.b4j.objects.LayoutBuilder.loadLayoutHeader(LayoutBuilder.java:221)
    at anywheresoftware.b4j.objects.LayoutBuilder.loadLayout(LayoutBuilder.java:101)
    at anywheresoftware.b4j.objects.PaneWrapper.LoadLayout(PaneWrapper.java:101)
    at b4j.pmon_visual_dev.xgui._createcurvelistitem(xgui.java:1463)
    at b4j.pmon_visual_dev.xgui$ResumableSub_getGraphCurveRecs.resume(xgui.java:2095)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:47)
    at jdk.internal.reflect.GeneratedMethodAccessor8.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.BA.raiseEvent(BA.java:78)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:42)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:136)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:85)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:487)
    at anywheresoftware.b4a.keywords.Common.access$0(Common.java:467)
    at anywheresoftware.b4a.keywords.Common$CallSubDelayedHelper.run(Common.java:541)
    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._enterNestedEventLoopImpl(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._enterNestedEventLoop(WinApplication.java:201)
    at javafx.graphics/com.sun.glass.ui.Application.enterNestedEventLoop(Application.java:509)
    at javafx.graphics/com.sun.glass.ui.EventLoop.enter(EventLoop.java:107)
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.enterNestedEventLoop(QuantumToolkit.java:591)
    at javafx.graphics/javafx.stage.Stage.showAndWait(Stage.java:465)
    at anywheresoftware.b4j.objects.Form.ShowAndWait(Form.java:232)
    at b4j.pmon_visual_dev.graphsetupformmodal._show(graphsetupformmodal.java:110)
    at b4j.pmon_visual_dev.main._btnsetup_click(main.java:2225)
    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: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.BA$1.run(BA.java:216)
    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)


I have attached the two layout files in a zip.

This one works:

LayoutOK.png



This one crashes:

LayoutThatCrashes.png


Can some one have a look at this problem please? I can't provide the entire project as it is very large and complex.

Additional:

I made a small test project which loads the two layouts into separate panes. The error still occurs in this environment. I am using B4J 8.5 with W:\MyProgramFiles_W\Java_11_0_1\bin\javac.exe.

Java Release Info:
IMPLEMENTOR="Oracle Corporation"
IMPLEMENTOR_VERSION="18.9"
JAVA_VERSION="11.0.1"
JAVA_VERSION_DATE="2018-10-16"
MODULES="java.base java.compiler java.datatransfer java.xml java.prefs java.desktop java.instrument java.logging java.management java.security.sasl java.naming java.rmi java.management.rmi java.net.http java.scripting java.security.jgss java.transaction.xa java.sql java.sql.rowset java.xml.crypto java.se java.smartcardio jdk.accessibility jdk.internal.vm.ci jdk.management jdk.unsupported jdk.internal.vm.compiler jdk.aot jdk.internal.jvmstat jdk.attach jdk.charsets jdk.compiler jdk.crypto.ec jdk.crypto.cryptoki jdk.crypto.mscapi jdk.dynalink jdk.internal.ed jdk.editpad jdk.hotspot.agent jdk.httpserver jdk.internal.le jdk.internal.opt jdk.internal.vm.compiler.management jdk.jartool jdk.javadoc jdk.jcmd jdk.management.agent jdk.jconsole jdk.jdeps jdk.jdwp.agent jdk.jdi jdk.jfr jdk.jlink jdk.jshell jdk.jsobject jdk.jstatd jdk.localedata jdk.management.jfr jdk.naming.dns jdk.naming.rmi jdk.net jdk.pack jdk.rmic jdk.scripting.nashorn jdk.scripting.nashorn.shell jdk.sctp jdk.security.auth jdk.security.jgss jdk.unsupported.desktop jdk.xml.dom jdk.zipfs"
OS_ARCH="x86_64"
OS_NAME="Windows"
SOURCE=".:8513ac27b651"



Best regards
Rob
 

Attachments

  • layoutFiles.zip
    5.4 KB · Views: 178
  • layoutFilesTestApp.zip
    8.3 KB · Views: 233
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0
Top