Develop a program with a tray icon in Java,
The Chinese display of other modules is normal, for example:
Just click on the small icon in the Tray pop-up menu in Chinese is the box (Chinese box), as follows:
As a general rule of thumb, if the font is not set, use the following code to set the font:
Font f = new Font ("\u5fae\u8f6f\u96c5\u9ed1", Font.plain, 11);//Arial
Uimanager.put ("Label.font", f);
Uimanager.put ("Label.foreground", Color.Black);
Uimanager.put ("Button.font", f);
Uimanager.put ("Menu.font", f);
Uimanager.put ("Menuitem.font", f);
Uimanager.put ("List.font", f);
Uimanager.put ("Checkbox.font", f);
Uimanager.put ("Radiobutton.font", f);
Uimanager.put ("Combobox.font", f);
Uimanager.put ("Textarea.font", f);
Uimanager.put ("Editorpane.font", f);
Uimanager.put ("Scrollpane.font", f);
Uimanager.put ("Tooltip.font", f);
Uimanager.put ("Textfield.font", f);
Uimanager.put ("Tableheader.font", f);
Uimanager.put ("Table.font", f);
Finished Chinese or block, then print the font with the following code:
Graphicsenvironment ge = graphicsenvironment.getlocalgraphicsenvironment ();
String script[] = Ge.getavailablefontfamilynames ();
for (String S:script) {
System.out.print (s+ ",");
}
Found clearly written there is a song body. This depressed, tried for an afternoon, still did not fix.
Finally found the savior on the Internet (see: http://scnjl.iteye.com/blog/1282172).
The original is myeclipse operation parameter problem, really want to curse ah I ...
Here's the solution:
First:
Right-click on your class with the main function, which is the main class where your app is running, and select Run configurations in Run as:
Second, add the following line parameter code to the VM arguments under the Arguments tab and click Apply.
-dfile.encoding=gb18030
OK, and then run, it finally appeared normal Chinese:
Finally finished, Haha,
No garbled, the whole world is pure!!!!
JAVA,AWT, Chinese box, Chinese garbled