• Post Reply Bookmark Topic Watch Topic
  • New Topic

Japanese text in Swing

 
M Easter
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Folks,

Short version: My project is having a display problem in Swing.

Background:

-- Swing app with JDK 1.4.x on Windows XP
-- Japanese fonts have been loaded from MS multi-lang pack
-- Regional/Language Options switched to Japanese. The OS is displaying Japanese all over the place (which is good)

Issue:

I have a string of Unicode text with Japanese characters. When I use a small example GUI and place the string in a JLabel, all is well.

Our full-blown app uses an internal toolkit for typical GUI components (e.g. a splashscreen). When the same string is displayed in the splashscreen, the display is the dreaded "boxes" instead of characters. When I augment the string to contain English and French (with diacritics), the Eng/French display properly but the Japanese is still boxes.

Question:

What could the toolkit be doing that messes this up? I noticed that we can give the splashscreen label a "font name" and "font size". I wonder if the JLabel in the splashscreen is using a font size that is different from the one in my example GUI?

More generally, I'm looking for any ideas/experiences on what could be different, or causing the problem.

Any help is _greatly_ appreciated...
Mike
[ March 04, 2007: Message edited by: M Easter ]
 
Campbell Ritchie
Marshal
Posts: 52581
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Difficult to be sure, but check that the splashscreen fully supports Unicode; I can get Japanese and Chinese characters on a pure Java app (JOptionPane) which print out as boxes on "System.out". Also check whether any of your characters uses a Unicode value >= 2^16. Unicode had to be extended beyond 16 bits to encompass eastern Asian scripts. Also check whether J2SE1.4 supports Unicode with 32 bits; I am pretty sure Java 5 and Java 6 do however.
 
M Easter
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem, as it turns out, was that the splashscreen used an internal GUI component which included a JLabel for the text.

The component read its text, font size, and font name from a property file. Unfortunately, it didn't pay any attention to the font name. So the label would invariably use the font 'Arial'.

I used Groovy to quickly mock up an example: the JLabel was protected, so I derived a new class and set the font directly. I used 'MS Arial Unicode' and all was well.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!