B4J Question [SOLVED] Proper usage of B4XPages.GetNativeParent(Me).Resizable

Tecuma

Member
Licensed User
Hello Community,

I am testing to disable resaizable with the information from this thread.
I am placing this code in Main in AppStart

B4X:
Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.Show
    'MainForm.Resizable = False
    #If b4j
    B4XPages.GetNativeParent(Me).Resizable = False
    #End If
    Dim PagesManager As B4XPagesManager
    PagesManager.Initialize(MainForm)
End Sub

When I try to run this code the App crashes.

B4X:
Waiting for debugger to connect...
Program started.
Error occurred on line: 15 (B4XPages)
java.lang.ClassCastException: class java.lang.Object cannot be cast to class b4j.example.b4xpagesmanager (java.lang.Object is in module java.base of loader 'bootstrap'; b4j.example.b4xpagesmanager is in unnamed module of loader 'app')
    at b4j.example.b4xpages._getmanager(b4xpages.java:118)
    at b4j.example.b4xpages._getnativeparent(b4xpages.java:40)
    at b4j.example.main._appstart(main.java:79)
    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: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.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.BA.raiseEvent2(BA.java:111)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
    at b4j.example.main.start(main.java:38)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
    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)

Is this not the proper place for this code?
 

Tecuma

Member
Licensed User
@aeric
Thanks.

I moved the code to the main page.
No crash.

When I want to have every Window I use to disable resize do I need this code in every B4XPage?
 
Upvote 0
Top