javaswingcharacter-encodingjlabeloff-by-one

JLabel text is garbled


I'm seeing a strange issue involving a JLabel that is used to display a range of numbers. The text of the label is typically something like 0.0 - 100.0 (for example). The problem is that for a select few users, the text appears garbled. In this example, the text would show up as /-/,0//-/.

Here's what I know so far:

What could cause this type of problem? What else should I investigate? Thanks.


Solution

  • This happens when you're setting the font of your JLabel to a font corrupted in the Windows font cache.

    To rebuild the cache: as administrator, delete this file and reboot the PC:

    del %WINDIR%\System32\FNTCACHE.DAT