B4J Question Form size with mismatched monitors [solved]

Didier9

Well-Known Member
Licensed User
Longtime User
I just received a new (to me) laptop with a 4k monitor today. I do have a 1080p monitor as a second display.
My app normally has a fixed size of approximately 600x600 and does not support a full screen mode. When I start the app on the 4k monitor, it looks fine (the same size as a fraction of the overall display as it did on the 1080p laptop I was using before) so in effect the OS is scaling the form and everything inside it by about 2x. When I move the app to the second display, it looks funny while the app spreads over the two monitors (since the app is scaled by 2x, it looks very big on the second display, until the app is completely on the 1080p display. Once moved to the second display, it is apparently rescaled and then it looks fine too.

The funky part is when I bring the app back on the laptop's 4k monitor. The app's form keeps the dimension in pixels it had on the 1080p display (so the form shrinks by about 50%) but the UI elements inside it are scaled back by ~2x, so the form is now too small to contain all the UI elements. I can move it back on the 1080p monitor and it will look fine again, but I can't put it back on the 4k display and have it look right. There is no recovery without shutting the app down.

B4J itself (or any of the other software I have tried) does not have that problem and properly rescales when going back and forth, with the same funky issue when the app straddles the two displays, but that goes away as soon as the app is fully on a single display.

This is a Dell Precision 5530 (about 2 1/2 years old) with Windows 10 Pro 20H2 and all the patches as of today, and mostly default settings for everything.

I suspect a display driver issue, but since only this B4J app does it, there may be something not set quite right in my app. The laptop has an NVIDIA Quadro P2000 graphic adapter, but I don't believe it runs when using business apps. The laptop otherwise has the integrated Intel HUD Graphics 630 hardware.

This is not a show stopper, just annoying. Any suggestion appreciated.
 

Attachments

  • 4k when app starts.png
    4k when app starts.png
    252.2 KB · Views: 221
  • 1080p display.png
    1080p display.png
    162.1 KB · Views: 209
  • back on 4k display.png
    back on 4k display.png
    283.6 KB · Views: 222
Last edited:

Didier9

Well-Known Member
Licensed User
Longtime User
Are you using Java 11+? Oracle made some improvements in the handling of hi dpi screens.
No, I have been using Java 8 because of the COM port issues with Java 11, and because I cannot use OpenSDK at work, but this is my home machine so I could try. I will check tonight.
 
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
This is actually good news, thanks for the link.
Does not help the situation at work. Actually, it's worse than you might think...
My company's IT department does not like free stuff, they prefer to pay for things...
Their word, not mine.
(then it was explained that the actual policy is not pay-versus-free, it's that they do not like open source and prefer commercial stuff. Specifically, they do like when software has a "publisher" so they can more easily support it with the Bit9/Carbon Black security software). Still getting any software install approved when it's not on the official list is a major undertaking.
I know...
 
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
I have made some progress.
I was handling form resize through the MainForm_Resize event.
In the previous incarnation of this app, I wanted the form to be fixed size, so I had this statement at the end of the Mainform_Resize event:
MainForm.SetWindowSizeLimits( windowWidth, windowHeight, windowWidth, windowHeight )
It would only execute that statement the second (and later) times the form was resized, so when I moved the form to the second display the first time, that statement would not execute and the form resized correctly. But when I moved it back to the main display, that line would execute and that's what caused the problem because windowHeight and windowWidth are in actual pixels, not scaled do dimensions.
I took this statement off and it works much better.

Now just the form title changes font size when switching windows.

This is what it looks like on the 4k display

1637337568990.png


and on the 1080p display:

1637336729431.png


The File Chooser is also affected, looking very big (but with normal proportions) on the 1080p monitor but normal size on the 4k display. I have no way (at the moment) to make the window appear on the 1080p display, the program always starts on the 4k display, so I do not know what would happen the other way around.
 

Attachments

  • 1637336661483.png
    1637336661483.png
    35.3 KB · Views: 205
  • 1637337537444.png
    1637337537444.png
    36.1 KB · Views: 183
Last edited:
Upvote 0
Top