B4J Question Hide/Show MainForm

ThRuST

Well-Known Member
Licensed User
Longtime User
Is it possible to hide and show MainForm from Visible True/False? When it set MainForm.Visible = False it says it's read only.
 

Cableguy

Expert
Licensed User
Longtime User
You Can use the forms alpha prop.
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Very impressive, thanks :)
Btw I tried to add you to Facebook but I couldn't find you. mind if I add you? my name is Roger Lindfors ([email protected]). I'll delete this line a little later.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Just sent u a mail
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
B4X:
Dim mf as JavaObject = MainForm.RootPane 
mf.RunMethodJO("getScene",Null).RunMethodJO("getWindow",Null).RunMethod("hide",Null)
...
Make sure you have another window open before you call this or app will terminate.
to see the form again, just use MainForm.Show again
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Thank you Daestrum. Do you know if visible property can be used instead because the solution to open a new form in this case means it have the second form minimized and that's not really what I want. I've tried the alpha way but the form turned white at alpha = 0. Cableguy might post an example if we're lucky :rolleyes:
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
I changed to TRANSPARENT form but it's just showing a white form when I tried this
B4X:
MainForm.RootPane.SetAlphaAnimated(0, 0)

Please provide your example how you make it work because I'm lost :eek:
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Set the background color to transparent, white is default color
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Since I used an AnchorPane in Scene builder 2 I had to do it like this, based on your guidande:

B4X:
Dim MainForm As Form
Dim MainPanel As AnchorPane

MainForm.RootPane.LoadLayout("Form1") 'Load the layout file.
MainForm.SetFormStyle("TRANSPARENT")
MainForm.Show
MainForm.BackColor = fx.Colors.Transparent
MainForm.RootPane.SetAlphaAnimated(0, 0)
MainPanel.Parent.Alpha = 1

Just change the MainPanel.Parent.Alpha to transparent range 0 - 1 (i.e. 0.5 for 50% transparency).
Please note that Form1 is a FXML file.
Many thanks Cableguy. I wouldn't have solved it without your 'hints' :)
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Btw, the AnchorPane should have the name MainPanel under Properties/Id field in Scene builder 2 for this example to work.
I hope this will help other wizards in this community :D
 
Upvote 0
Top