Weblookandfeel garbled Problem Solving method __swing

Source: Internet
Author: User
phenomena

Swing to write the interface, feel too ugly, using WEBLAF changed the interface. But Chinese is always garbled.

If you do not use WEBLAF, it is normal. reason

Google took a look at the project home page.
The Swing default font has Chinese.
The default font set by Weblaf does not have Chinese in it.
The system can not find Chinese characters in the font, the display garbled.
This is the default font setting for Com.alee.laf.WebFonts

    static {
        if (systemutils.iswindows ()) {
            fonts.put ("Control", New Fontuiresource ("Tahoma", 0,));
            Fonts.put ("alert", New Fontuiresource ("Segoe UI", 0);
            Fonts.put ("menu", New Fontuiresource ("Segoe UI", 0);
            Fonts.put ("accelerator", New Fontuiresource ("Segoe UI", 0,));
            Fonts.put ("title", New Fontuiresource ("Segoe UI", 0);
            Fonts.put ("text", New Fontuiresource ("Tahoma", 0,));
            Fonts.put ("tooltip", New Fontuiresource ("Segoe UI", 0,));
            else if (....
//...           
}

See also: Unicode support? Solving Method

Set the font in the Weblaf yourself.
As the following code, set to the script. Chinese is displayed normally.

                Weblookandfeel.globalcontrolfont  = new Fontuiresource ("Official script", 0);              Weblookandfeel.globaltooltipfont
//              Weblookandfeel.globalalertfont
//              Weblookandfeel.globalmenufont
//              Weblookandfeel.globalacceleratorfont
//              Weblookandfeel.globaltitlefont
//              Weblookandfeel.globaltextfont

                weblookandfeel.install ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.