Tuesday, July 7, 2015

How to fix JAVA garbled/broken text rendering on buttons in swing (eclipse, netbeans)


As you start exploring the world of Swing, JFrames, JButtons etc, it's probable that you ran into a problem where the text on your buttons and frame are all garbled up, broken, ripped, whatever else you call it.

This happens when there's a conflict between swing's rendering and your graphics card, but fear not, below are a list of fixes and you may chose what works best for you!

Fix 1 - Use a dedicated GPU with java (Semi recommended)

Open up your dedicated graphics card's control panel (in my case, NVidia), then select or add a new program, browse the following folder : "C:\Program files\java\jre1.8.0_20\bin\javaw.exe" (jre1.8.0.20 is your java version, so it depends.) then select "dedicated gpu" as preferred graphics processor.

This will solve the problem in eclipse, but sometimes not in Netbeans, so let's move on to the next solution.

Fix 2 - Disable cleartype (Not recommended)


Another temporary fix to this problem is to disable cleartype, a visual text amelioration in Windows machines, you can find this by going to your start menu and typing "Cleartype", from there, you can edit or temporarily check/uncheck the "enable cleartype" option. This will fix your problem, but then you will be left with ugly font rendering while browsing the internet and using your computer.

Fix 3 - Update your graphics card driver (Best fix)


This method is the simplest but also what I consider the "norm" fix for this problem, as it solved mine without having to always use my dedicated graphics card or disable cleartype.

You just lookup your Graphics card model, go to google and search for drivers for that one card, remember to get your drivers from official websites if possible in my case "intel HD 4000 driver", after installation, you will need to reboot your computer and then you're good to go! no more ugly text rendering.

Let me know if this hasn't fixed the problem but I hope it worked for you too.

No comments:

Post a Comment