B4J Question managing Minimize, Maximize and Close events

Cableguy

Expert
Licensed User
Longtime User
Hi Guys

How can I manage the top-right options? (Minimize, Maximize/Restore, Close)
I'm using the code snippet in B4J How-To's to make my app full screen, BUT it's not the same as setting it to Maximize. How can I manage those states?

I found how to Maximize a Form:
B4X:
Sub SetMaximized(frm As Form)
  Dim joForm As JavaObject = frm
  Dim joStage As JavaObject = joForm.GetField("stage")
  joStage.RunMethod("setMaximized", Array(True))
End Sub

But how to catch those events to act upon? like screensize_changed kinda of event
 
Last edited:

Roycefer

Well-Known Member
Licensed User
Longtime User
Forms have a _Closed and a _CloseRequested() event. For Maximize and Unmaximize, you can use the AnchorPane's _Resize event. Forms also have a _FocusChanged event that you can use to help detect Minimize though they also fire when focus is merely taken out of the Form and the Form isn't minimized.

As for making the Form truly Maximized, this code should set you in the right direction:
B4X:
Dim mf As JavaObject = MainForm
mf.GetFieldJO("stage").RunMethod("setFullScreen", Array(True))
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
FullScreen is not exactly what I need, simply because it hides all the decorations and system tray.
I was under the impression that an anchorpane is yet another "view"...??
 
Upvote 0
Top