Swing tip. Set the global font (Sun JDK)

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 the 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 ("effectopicon. 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.