Bug? Window Size

stevel05

Expert
Licensed User
Longtime User
I am trying to align objects to an image and have added an image with css, no problem there. The only issue is that the window size appears to be slightly larger than the preferred size.

I have constrained the window size in project attributes and the height and width of the main form reports what I expect the size to be. If you compare the image in the app window with the image in the designer, the image appears to be slightly bigger in the app window.

Example project attached.

[Edit] example ImageSize1 uses an absolute sized image with on repeat in the css.

Just to clarify it appears that the window in the app is larger than the preferred size, even though the returned values are as they should be.
 

Attachments

  • ImageSize.zip
    12 KB · Views: 229
  • ImageSize1.zip
    12.1 KB · Views: 208
Last edited:

agraham

Expert
Licensed User
Longtime User
There is no css file in either zip but it is not necessary to see the problem. It seems that specifying MainForm.Resizable=False causes an increase in size of 10 pixels in both dimensions. Without it the size is correct.

EDIT: The css file is there but in the wrong folder. It and the background should be added to the Files folder and the path in the xml changed to <URL value="@HST.css" />
 
Last edited:

stevel05

Expert
Licensed User
Longtime User
Thanks Agraham,

OK, I have changed the location, it does make more sense.

And yes, without the resizable=False the image is displayed correctly, although in both cases the Height and Width are reported the same.

The added size appears to be different for different sized windows, I'll test further tomorrow.
 
Last edited:

agraham

Expert
Licensed User
Longtime User
The incorrect values show up if you do the logging after Showing the Form not before. As far as I can see it is a bug in JavaFX itself. Here is a crude workaround to get a non-resizable window of the required size.
B4X:
#Region  Project Attributes
    #MainFormWidth: 200
    #MainFormHeight: 210
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form

    Dim MainFormWidth As Int = 200
    Dim MainFormHeight As Int = 210
   
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("1") 'Load the layout file.
   
    MainForm.Resizable=False
    MainForm.Show
   
    Log(MainForm.RootPane.Width & " " & MainForm.WindowWidth)
    Log(MainForm.RootPane.Height & " " & MainForm.WindowHeight)
   
    MainForm.WindowWidth = MainForm.WindowWidth - (MainForm.RootPane.Width - MainFormWidth)
    MainForm.WindowHeight = MainForm.WindowHeight - (MainForm.RootPane.Height - MainFormHeight)
   
    Log(MainForm.RootPane.Width & " " & MainForm.WindowWidth)
    Log(MainForm.RootPane.Height & " " & MainForm.WindowHeight)
   
   
End Sub
 

stevel05

Expert
Licensed User
Longtime User
Yes that looks good, thanks Andrew.
 

BPak

Active Member
Licensed User
Longtime User
The incorrect values show up if you do the logging after Showing the Form not before. As far as I can see it is a bug in JavaFX itself. Here is a crude workaround to get a non-resizable window of the required size.
B4X:
#Region  Project Attributes
    #MainFormWidth: 200
    #MainFormHeight: 210
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form

    Dim MainFormWidth As Int = 200
    Dim MainFormHeight As Int = 210

End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("1") 'Load the layout file.

    MainForm.Resizable=False
    MainForm.Show

    Log(MainForm.RootPane.Width & " " & MainForm.WindowWidth)
    Log(MainForm.RootPane.Height & " " & MainForm.WindowHeight)

    MainForm.WindowWidth = MainForm.WindowWidth - (MainForm.RootPane.Width - MainFormWidth)
    MainForm.WindowHeight = MainForm.WindowHeight - (MainForm.RootPane.Height - MainFormHeight)

    Log(MainForm.RootPane.Width & " " & MainForm.WindowWidth)
    Log(MainForm.RootPane.Height & " " & MainForm.WindowHeight)


End Sub

You can use different SetFormStyle settings and have the Designer size screen.

For Resizable windows
B4X:
MainForm.RootPane.LoadLayout("lay1") 
MainForm.Title = "Window is Resizable"
MainForm.SetFormStyle("DECORATED")		' Default Setting
MainForm.Resizable = True				' Default Setting
MainForm.Show
For Windows NOT Resizable
B4X:
MainForm.RootPane.LoadLayout("lay1") 
MainForm.Title = "Window is NOT Resizable"
MainForm.SetFormStyle("UTILITY")
MainForm.Resizable = False
MainForm.Show
Both settings will show the Designer size window as long as it is not overridden in the Project Attributes.
 
Last edited:
Top