B4J Question unsupported ui elements

barx

Well-Known Member
Licensed User
Longtime User
So, I have finally decided to try out b4j. i liked the idea of the internal designer but soon realised that it missed a lot of the elements available in the scene builder.

not a problem I thought, Just create the layout with scene builder then code in b4j. The problem is whenever I add an Accordian view b4j throws an error

Program started.
Error occurred on line: 20 (main).
java.lang.NullPointerException
at anywheresoftware.b4j.objects.FXMLBuilder.handleNode(FXMLBuilder.java:215)
at anywheresoftware.b4j.objects.FXMLBuilder.setEventsAndVariables(FXMLBuilder.java:153)
at anywheresoftware.b4j.objects.FXMLBuilder.setEventsAndVariables(FXMLBuilder.java:209)
at anywheresoftware.b4j.objects.FXMLBuilder.setEventsAndVariables(FXMLBuilder.java:209)
at anywheresoftware.b4j.objects.FXMLBuilder.setEventsAndVariables(FXMLBuilder.java:209)
at anywheresoftware.b4j.objects.FXMLBuilder.setEventsAndVariables(FXMLBuilder.java:209)
at anywheresoftware.b4j.objects.FXMLBuilder.setEventsAndVariables(FXMLBuilder.java:209)
at anywheresoftware.b4j.objects.FXMLBuilder.LoadLayout(FXMLBuilder.java:118)
at anywheresoftware.b4j.objects.PaneWrapper.LoadLayout(PaneWrapper.java:71)
at b4j.example.main._appstart(main.java:80)
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/678442457.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/1877086202.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)

Is there anyay round this?
Are the missing elements likely to be added to b4j designer?
Am i just doing something wrong? Afterall I have been using b4j about 2 hours.

Thanks
 

stevel05

Expert
Licensed User
Longtime User
I don't get an error here, can you post your project?
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
I don't get an error here, can you post your project?

Nothing worth posting, the b4j project literally contains

B4X:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
'    Private mSQL As SQL
    Private iconAdd, iconPrefs, iconReport, iconSearch As Label
    Private btnCloseSearch As Button
    Private mnuSearch As AnchorPane
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.SetFormStyle("UTILITY")
    MainForm.Title = "v1.0"
    MainForm.RootPane.LoadLayout("Main") 'Load the layout file.
    MainForm.Resizable = False
    MainForm.Show

    'mSQL.InitializeSQLite(File.DirApp, "DMS", False)
   
End Sub
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
The scene layout is attached if that helps.
 

Attachments

  • Main.zip
    1.1 KB · Views: 222
Upvote 0

Roycefer

Well-Known Member
Licensed User
Longtime User
I don't see an any Accordions in your Process_Globals (they will be represented by Node variables). Did you forget to Generate Members on them? You also haven't set the Node Ids to many of the Nodes in your fxml file (including the Accordion). You won't be able to handle their events or change their attributes without a Node Id.
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
I don't see an any Accordions in your Process_Globals (they will be represented by Node variables). Did you forget to Generate Members on them? You also haven't set the Node Ids to many of the Nodes in your fxml file (including the Accordion). You won't be able to handle their events or change their attributes without a Node Id.
I was just playing with us ideas. The error only occurred when I added the accordion. There doesn't seem to be an object to declare as accordion from what I can see.
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
I can post the project in the morning if it will help.

Thanks so far
 
Upvote 0

Roycefer

Well-Known Member
Licensed User
Longtime User
No, you don't create an Accordion object in B4J. Give the Accordion a Node Id in SceneBuilder and then Generate Members. You will get a Node variable of the same name in your B4J code.
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
No, you don't create an Accordion object in B4J. Give the Accordion a Node Id in SceneBuilder and then Generate Members. You will get a Node variable of the same name in your B4J code.
Ok, so this morning I named and generated the Accordion. Sill no joy. So I also Named and Generated the title panes, no joy. So I thought maybe you HAVE to implements click methods, so I generated those, still no joy...

I have attached the project so you can see yourself

Cheers
 

Attachments

  • DMS Order.zip
    3.9 KB · Views: 206
Upvote 0

Ed Brown

Active Member
Licensed User
Longtime User
Hello @barx

I can replicate the issue easily enough. All I'm doing is starting a new B4J project, adding a new layout using FXML, to the layout I add the 'Accordion (empty)' control. Next, I run the project after saving the layout and I get the error.

I've also tried replacing the 'empty' control with the other 'Accordion' control and re-ran the project and no error showed.

Finally, I removed the contents of each 'TitledPane' to effectively make it the same as the 'empty' Accordion and the same error again occurs when I run the project.

If you are able to make use of the non-empty Accordion control then that might be the solution for you. Otherwise, I would think this needs to be reported as a bug.

Apologies for not being able to provide a useful work-around for you.
 
Upvote 0

rwblinn

Well-Known Member
Licensed User
Longtime User
Hi,

I confirm same error as outlined in post #10.

A workaround is to add at least one control (like button, textfield...) to each of the empty titledpanes. Have tested this and is working ok.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
As rwblinn suggests, if the titledpanes are empty the error occurs, in your example, By Postcode is empty, adding an anchor pane removes the error.
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
Hello @barx

I can replicate the issue easily enough. All I'm doing is starting a new B4J project, adding a new layout using FXML, to the layout I add the 'Accordion (empty)' control. Next, I run the project after saving the layout and I get the error.

I've also tried replacing the 'empty' control with the other 'Accordion' control and re-ran the project and no error showed.

Finally, I removed the contents of each 'TitledPane' to effectively make it the same as the 'empty' Accordion and the same error again occurs when I run the project.

If you are able to make use of the non-empty Accordion control then that might be the solution for you. Otherwise, I would think this needs to be reported as a bug.

Apologies for not being able to provide a useful work-around for you.
Hi,

I confirm same error as outlined in post #10.

A workaround is to add at least one control (like button, textfield...) to each of the empty titledpanes. Have tested this and is working ok.
As rwblinn suggests, if the titledpanes are empty the error occurs, in your example, By Postcode is empty, adding an anchor pane removes the error.

Thanks for this guys, Obviously an accordion would contain other views, I just hadn't added them yet. So had i gone a little further with the layout the error would have gone. Guess I got a little too eager with the 'checking out how it looks'.

Thanks again
 
Upvote 0
Top