Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UTF-8 character is not proper in JOptionPane

Please find the below sample code, The UTF-8 character properly displaying in windows machine. But, its not proper for Linux machine (Ubuntu).

import javax.swing.JOptionPane;

public class JContPaneTest 
{
  public static void main(String[] args) 
  {
    JOptionPane.showMessageDialog(null, "\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3002\u30c7\u30fc\u30bf\u30d9\u30fc", "Error",JOptionPane.ERROR_MESSAGE);
  }
}

Is there any way to solve this problem?

like image 440
sprabhakaran Avatar asked Apr 29 '13 06:04

sprabhakaran


1 Answers

Not all fonts contain the full unicode set of glyphs. The blobs are probably the result of a deficient font, but in java it's hard to determine what font is actually being used, and I don't know a way to determine if these blobs are being emitted except by seeing them.

I had huge problems with unicode in pop-up menus, which probably is a very similar problem to yours.

2 things to try.

1) Write a font test to display your string in all fonts that are available to java. 2) Try using a non-swing component. Non-swing components use the underlying OS font support.

like image 173
ddyer Avatar answered Oct 13 '22 22:10

ddyer