B4J Question MainWindow Height and Width

stefanoxjx

Active Member
Licensed User
Longtime User
Hi,
I'm trying to have width of mainwindow.
Why MainForm.WindowWidth return NaN, and MainForm.Width return 0?
How I can to have this value?
I hope that somebody could help me.
Thanks.

Stefano
 

stefanoxjx

Active Member
Licensed User
Longtime User
Hi Erel,
I'm developing a stupid program only to know the potentiality of B4J.
This is code:
B4X:
Version=2.5
AppType=JavaFX
IconFile=
NumberOfModules=0
Build1=Default,b4j.example
NumberOfFiles=1
File1=Principale.fxml
NumberOfLibraries=2
Library1=jcore
Library2=jfx
@EndOfDesignText@
#Region  Project Attributes  
   #MainFormWidth: 800
   #MainFormHeight: 600  
#End Region
Sub Process_Globals
   Private fx As JFX
   Private MainForm As Form
   Private btnMostra As Button
   Private btnNascondi As Button
   Private webPanel As WebView
   Private lblText As Label
   Private imgView As ImageView
   
   Dim x As Int
End Sub
Sub AppStart (Form1 As Form, Args() As String)
   MainForm = Form1
   MainForm.Initialize("MainForm", -1 , -1)
   MainForm.RootPane.LoadLayout("Principale") 'Load the layout file.
   
   webPanel.Left=10
   lblText.Text=MainForm.WindowWidth 
   lblText.Text=MainForm.Width 
   
   webPanel.LoadUrl("http://www.google.it")
   'imgView.SetImage(webPanel.LoadUrl("http://192.168.0.98:8081"))
   MainForm.Show
End Sub
Sub btnMostra_MousePressed (EventData As MouseEvent)
  x=x+1
    lblText.Text=x
   
End Sub
Sub btnNascondi_Action
   x=x-1
     lblText.Text=x
End Sub
Sub btnEsci_Action
   ExitApplication
     
End Sub

The line: lblText.Text=MainForm.WindowWidth return "NaN"
nan.png






and lblText.Text=MainForm.Width return "0"
0.png


I would like to use this value to change dinamically the dimension of object in window.

Thanks :)

Stefano
 
Upvote 0
Top