I have a main form which is loaded and occupies the whole screen.
I load another form loaded from a code module which opens on top of the main form on the right half of the screen and needs to stay on top so I use form.showandwait in the 2nd module.
My problem is I need to move focus back to the main form to scroll thru a table view but keep the 2nd form open and on top then move focus back to the second form.
If I just use form.show the 2nd form disappears behind the main form but I need keep it on top.
Its not a problem if both forms are in the same code module but I have multiple popup forms that need to switch focus between itself and the main form.
This woks as long as you set "Private Mainform as Form" to Public
If you close the second form and try to open it again I get an error:
Error occurred on line: 21 (RightForm) java.lang.IllegalStateException: Cannot set owner once stage has been set visible
at javafx.stage.Stage.initOwner(Stage.java:561)
at anywheresoftware.b4j.objects.Form.SetOwner(Form.java:222)
at b4j.example.rightform._show(rightform.java:63)
at b4j.example.main._btnright_mouseclicked(main.java:118)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
...
AlwaysOnTop(MainForm,True) ' this could be any form
End Sub
private Sub getStage(o As JavaObject) As JavaObject
Return o.GetFieldJO("stage")
End Sub
Sub AlwaysOnTop(o As Form,boo As Boolean)
getStage(o).RunMethod("setAlwaysOnTop",Array(boo))
End Sub