Swing tip. Set the global font

Source: Internet
Author: User
Swing tip. Set the global font (Sun JDK)

Why?

Because the default font display in Java is ugly

Because skin such as jgoodies does not support Chinese characters by default

Because jdk1.4 has a serious bug in mapping Chinese fonts, anyone who has used idea knows that

Because only sun's JDK is available, IBM's and Bea's are not suitable for running the client.

If you are smart ....

// Set global font
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 );
}
}

If you aren't...

Font font =   New Font ( " Dialog " , Font. Plain, 12 );
Uimanager. Put ( " Tooltip. Font " , Font );
Uimanager. Put ( " Table. Font " , Font );
Uimanager. Put ( " Tableheader. Font " , Font );
Uimanager. Put ( " Textfield. Font " , Font );
Uimanager. Put ( " ComboBox. Font " , Font );
Uimanager. Put ( " Textfield. Font " , Font );
Uimanager. Put ( " Passwordfield. Font " , Font );
Uimanager. Put ( " Textarea. Font " , Font );
Uimanager. Put ( " Textpane. Font " , Font );
Uimanager. Put ( " Editorpane. Font " , Font );
Uimanager. Put ( " Formattedtextfield. Font " , Font );
Uimanager. Put ( " Button. Font " , Font );
Uimanager. Put ( " Checkbox. Font " , Font );
Uimanager. Put ( " Radiobutton. Font " , Font );
Uimanager. Put ( " Togglebutton. Font " , Font );
Uimanager. Put ( " Progressbar. Font " , Font );
Uimanager. Put ( " Desktopicon. Font " , Font );
Uimanager. Put ( " Titledborder. Font " , Font );
Uimanager. Put ( " Label. Font " , Font );
Uimanager. Put ( " List. Font " , Font );
Uimanager. Put ( " Tabbedpane. Font " , Font );
Uimanager. Put ( " Menubar. Font " , Font );
Uimanager. Put ( " Menu. Font " , Font );
Uimanager. Put ( " Menuitem. Font " , Font );
Uimanager. Put ( " Popupmenu. Font " , Font );
Uimanager. Put ( " Checkboxmenuitem. Font " , Font );
Uimanager. Put ( " Radiobuttonmenuitem. Font " , Font );
Uimanager. Put ( " Spinner. Font " , Font );
Uimanager. Put ( " Tree. Font " , Font );
Uimanager. Put ( " Toolbar. Font " , Font );
Uimanager. Put ( " Optionpane. messagefont " , Font );
Uimanager. Put ( " Optionpane. buttonfont " , Font );

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.