First of all, I would like to thank cocould for replying and reminding me.
Keywords: Swing jgoodies look & feel Chinese Characters
In the previous article, we mentioned that the use of third-party L & F to make the interface of Java programs more beautiful, but the Chinese characters of jgoodies L & F are changed to boxes. In addition, swing metal displays 12 bold Chinese characters by default, which is very ugly. Is there a way to display Chinese properly and be beautiful?
After looking for some information, we found that the Tohoma font is used by default in swing, rather than family font such as dialog. To display Chinese properly, set the font to dialog. It is difficult to set the font for each component in the cocould method. The following uses the Global font settings to solve this problem.
Public static void initglobalfontsetting (font fnt ){
Fontuiresource fontres = new fontuiresource (fnt );
For (enumeration keys = uimanager. getdefaults (). Keys (); keys. hasmoreelements ();){
Object key = keys. nextelement ();
Object value = uimanager. Get (key );
If (value instanceof fontuiresource)
Uimanager. Put (Key, fontres );
}
}
...........
Try {
Uimanager. setlookandfeel (
// Uimanager. getcrossplatformlookandfeelclassname ()
// Uimanager. getsystemlookandfeelclassname ()
// New COM. Sun. java. Swing. plaf. motif. motiflookandfeel ()
// "Com. jgoodies. Looks. Windows. windowslookandfeel"
"Com. jgoodies. Looks. Plastic. plasticlookandfeel"
// "Com. jgoodies. Looks. Plastic. plastic3dlookandfeel"
// "Com. jgoodies. Looks. Plastic. plasticxplookandfeel"
);
Initglobalfontsetting (new font ("dialog", Font. Plain, 12 ));
}
This completes. Let's take a look at the effect: