B4J Question XUI.MsgBoxAsync displays only 2 lines of text when not in focus

Diceman

Active Member
Licensed User
I am using jXUI v1.80 and I noticed at times when I call XUI.MsgBoxAsync(MyMsg, MyTitle), it will display the text for the long string in MyMsg wrapped in the dialog window but it will only display the first 2 lines. The 2nd line will mysteriously end in "..." indicating not all of the text was displayed. The text should have wrapped onto 3 lines but the 3rd line is missing.

I printed the text in the Log just before calling the MsgBoxAsync() and the text is all there, but does not always get displayed by MsgBoxAsync. Occasionally it will display the entire line wrapped onto 3 lines, but most of the time it will display the text only on 2 lines with the last line truncated.

I just found out what is what is causing the problem. The 3 lines will get displayed properly if the B4J app has focus. As soon as I click on another program and the B4J app loses focus, the dialog truncates the text to 2 lines and the 2nd line will now end in "...". This also causes a problem if the MsgBoxAsync gets called in a delayed event when the app is not in focus, it will truncate the message to 2 lines and there is no way to get the 3rd line displayed, even if I click on the dialog window so the B4J app is now in focus. This is annoying.

Has anyone else noticed this? Is there a way to get it to display more than 2 lines when the app is not in focus?

TIA
 

Diceman

Active Member
Licensed User
Does it behave differently if you use fx.Msgbox (not XUI)?

It doesn't seem to make a difference if I use XUI.MsgBox or fx.MsgBox. The text is truncated under certain conditions.

I have written a small test app that demonstrates the problem. Oddly enough, if I send a lot of text to the msgbox it will display fine. But if I limit the text to 128 or 255 characters, it gets truncated to 2 or 3 lines. And when the app loses focus, the 3rd line in the msgbox disappears.

I am using B4J v 6.51 with jXUI v1.80 on Win7 64bit

If someone can determine what's going on, I'd appreciate it. :confused:
TIA
 

Attachments

  • BugMsgBoxTruncate.zip
    3.9 KB · Views: 189
Upvote 0

stevel05

Expert
Licensed User
Longtime User
It appears to work correctly here, what version of JRE / JDK are you using?
 
Upvote 0

Diceman

Active Member
Licensed User
It appears to work correctly here, what version of JRE / JDK are you using?
I am using jdk 10.0.2

Are you seeing the dialog below (for 256 characters)? Or do you see the text ending in "]".
TIA

DialogBug.png
DialogBug.png
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Yes text ending with "]"
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
I'm using jdk1.8.0_181
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Just for clarification, I moved focus from the app, put it in the background and came back to it and it was still OK.
 
Upvote 0

Diceman

Active Member
Licensed User
Just for clarification, I moved focus from the appI'm using 6.51, put it in the background and came back to it and it was still OK.

It appears the problem is with JDK 10.0.2 (64bit)

I changed the Paths Configuration from:
C:\Program Files\Java\jdk-10.0.2\bin\javac.exe
to
C:\Program Files (x86)\Java\jdk1.8.0_121\bin\javac.exe

which is an older 32 bit jdk and it works fine. :rolleyes:
 
Upvote 0

Diceman

Active Member
Licensed User
Out of curiosity, did you try changing the scaling of the UI as in : https://www.b4x.com/android/forum/threads/java-9.84236/#post-534160

I did as you suggested and added:
#VirtualMachineArgs: -Dglass.win.uiScale=100%

to the B4J app and now both message boxes work under JDK 10.0.2. (no missing text)
Thanks for the suggestion. :)

The question is why did it solve the problem? I can understand if it consistently truncated 25% of the lines because it would mean it was incorrectly measuring the height of the text because the text was roughly 25% larger.

Here is what I discovered when using JDK 10.0.2 and 125% text scaling:
Line length between 1 and 233: Displays up to 4 lines of text correctly in the dialog with the enclosing "[ ]"
Line length between 234 and 360: Displays only the first 2 lines of text with last line ending in "...". It looks like "[ ...". The other lines of text do not appear.
Line length greater than 360: Displays all lines correctly with the enclosing "[ ]".​

For some reason the problem only occurs when displaying test with a length between 234 and 360 characters and the default text scaling of 125%. The message I was displaying just so happened to fall within that range and was truncated.

Like I said before, when I went back to using JDK 8, the message dialog displayed the text correctly. (It could have defaulted to 100% scaling instead of 125%?)
When I switched to 100% scaling instead of 125% with JDK 10.0.2, the message dialog display the text correctly.

Thanks again for the tip.:D
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
I believe the change to 125% was made in Java 9. I'm glad it fixed it.
 
Upvote 0
Top