Swing技巧. 设置全局字体(sun jdk)

Swing技巧. 设置全局字体(sun jdk)

为什么要这么做?

   因为java默认的字体显示中文都很难看

   因为比如jgoodies这样的skin默认不支持中文

   因为jdk1.4中文字体mapping有严重bug,用过IDEA的人都知道

   因为大家只有sun的jdk可用,ibm的,bea的都不适合跑client

if you are smart....
// 设置全局字体
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); 
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值