by Njål

Displaying Chinese Characters in Java Swing (JLabel)

 

When opening files with chinese characters in my Java 6 Application – the JLabel displayed squares instead of the proper filename:

image

 

log4j logged the filename correctly

Nytt 提供.docx

so I figured it was a font problem. I tried Arial, Verdana, Tahoma, Serif and so on. Nothing worked.

 

Then I tried this setting on the JLabel in Netbeans:

image

 

and this seems to resolve the issue!
image

 

The Java equivalent of the Netbeans setting is:

jlDesc.setFont(jlDesc.getFont().deriveFont(jlDesc.getFont().getSize()-1f));