B4J Question How to set form as maximized on load

Credo

Member
Hi, I found a few threads On how to set form as maximize.
It does not seem to be working on my end.




Maximizing form on load:
Sub Class_Globals
    Private Root As B4XView 'ignore
    Private xui As XUI 'ignore
    
End Sub

'You can add more parameters here.
Public Sub Initialize As Object
    Return Me
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    'load the layout to Root
    SetMaximized(Root)
    Root.LoadLayout("dashboard")
    
End Sub

'Sub FullScreen(Frm As Form)
'    Dim joForm As JavaObject = Frm
'    Dim joStage As JavaObject = joForm.GetField("stage")
'    joStage.RunMethod("setMaximized", Array(True))
'End Sub


Sub SetMaximized(frm As Form)
    Dim joForm As JavaObject = frm
    Dim joStage As JavaObject = joForm.GetField("stage")
    joStage.RunMethod("setMaximized", Array(True))
End Sub







Error occurred on line: 16 (dashboard)
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:119)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:486)
at b4j.example.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:876)
at b4j.example.b4xpagesmanager._showpageandremovepreviouspages(b4xpagesmanager.java:399)
at b4j.example.b4xpages._showpageandremovepreviouspages(b4xpages.java:56)
at b4j.example.b4xmainpage._jobdone(b4xmainpage.java:163)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
 
Top