Jump to content

The Java Swing program has always had UI misalignment problems

HolyGu

First, the computer configuration is as follows

 

Operating system: Windows10 20H2 / Windows10 1909 (both are the original versions downloaded from MSDN)
Motherboard: ASUS Z490-E / ASUS C8DH
CPU: i9-10850K / Ryzen9 5950X
Memory: Corsair DDR4 3600 16G2 / Acer DDR4 3600 16G2
Graphics card: ASUS 6900XT / ASUS 3090
Hard Disk: Toshiba RD20 / Hikvision C2000 Pro
Power: ApexGaming AJ-850M
Display: DELL U2417H / DELL U2720Q
JDK: 1.8/13

 

In the above two sets of configurations, the UI program written by Swing is run. During use, if the Chinese input method is triggered, the software layout will be disordered.

Bothered me for a long time. . . Please help

 

For example, when running the simplest example of Swing login box, the UI will be messed up when inputting Chinese.
But testing software written in JavaFX is normal

 

1.thumb.png.bc623671c031d0dddb5e60e9d9e554c7.png

 

2.thumb.jpg.054df9616706d4b31db19aa2438d0006.jpg

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, Sakuriru said:

JavaFX has supplanted Swing, if there's a choice use JavaFX.

However, some software currently in use, such as BurpSuite, CobaltStrike, etc., is still based on Swing and cannot be used normally at present.

Link to comment
Share on other sites

Link to post
Share on other sites

23 hours ago, Sakuriru said:

That's strange. If I had to guess it's because it's not correctly calculating the width of the characters. I don't really know if there's anything you can do to fix it on your end, but it's definitely a bug with Swing in general. You can always submit a bug report.

Thanks for your help, I found a temporary solution on the website stackoverflow.

 

https://stackoverflow.com/questions/22737535/swing-rendering-appears-broken-in-jdk-1-8-correct-in-jdk-1-7#

Created a J2D_D3D variable and set its value to false.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×