<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Picses' sky

    Picses' sky
    posts - 43, comments - 29, trackbacks - 0, articles - 24

    Swing技巧. 設(shè)置全局字體[zz]

    Posted on 2007-07-23 08:16 Matthew Chen 閱讀(1016) 評論(0)  編輯  收藏 所屬分類: Java SE

    Swing技巧. 設(shè)置全局字體

    Swing技巧. 設(shè)置全局字體(sun jdk)

    為什么要這么做?

       因為java默認(rèn)的字體顯示中文都很難看

       因為比如jgoodies這樣的skin默認(rèn)不支持中文

       因為jdk1.4中文字體mapping有嚴(yán)重bug,用過IDEA的人都知道

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

    if you are smart....
    //設(shè)置全局字體
    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); 

    posted on 2005-07-20 17:33 tech.cap 閱讀(2194) 評論(3)  編輯 收藏 引用 所屬分類: java 、tips

    Feedback

    # re: Swing技巧. 設(shè)置全局字體 2005-07-20 20:12 dudu

    建設(shè)不要這樣直接貼代碼, 交流思想才是重要的。  回復(fù)  更多評論   

    # re: Swing技巧. 設(shè)置全局字體 2005-07-21 01:01 cap

    ok, i see  回復(fù)  更多評論   

    # re: Swing技巧. 設(shè)置全局字體 2005-12-24 18:24 cofbean

    次方法的調(diào)用必須放在UIManager.setLookAndFeel(w);之后,因為具體的laf實現(xiàn)可能添加新的鍵值對。并且方法修改如下:

    //設(shè)置全局字體
    public static void initGlobalFontSetting(String font){

    for(Enumeration keys = UIManager.getDefaults().keys(); keys.hasMoreElements();){

    Object key = keys.nextElement();
    Object value = UIManager.get(key);

    if(value instanceof FontUIResource){
    FontUIResource rs=(FontUIResource)value;
    Font fontRes = new Font(font,rs.getStyle(),rs.getSize());
    UIManager.put(key, new FontUIResource(fontRes));

    }
    }

    主站蜘蛛池模板: 99精品免费视品| 国内精自视频品线六区免费| 国产亚洲精品精品国产亚洲综合| 精品国产一区二区三区免费| 亚洲综合激情另类小说区| 日韩精品免费电影| 亚欧乱色国产精品免费视频| 亚洲精品国产啊女成拍色拍| 国产国产人免费人成免费视频 | 中文字幕亚洲综合久久菠萝蜜| 久久99热精品免费观看牛牛| 久久亚洲国产最新网站| 国产性爱在线观看亚洲黄色一级片| 18以下岁毛片在免费播放| 最好2018中文免费视频| 亚洲天堂一区在线| 亚洲最大AV网站在线观看| 色婷婷7777免费视频在线观看| 2022免费国产精品福利在线| 亚洲av乱码一区二区三区 | 亚洲国产综合AV在线观看| 亚洲成A∨人片在线观看不卡| 国产精品黄页在线播放免费| 91老湿机福利免费体验| 永久免费精品影视网站| 美女视频黄免费亚洲| 午夜亚洲AV日韩AV无码大全| 亚洲国产成人乱码精品女人久久久不卡| 精品无码AV无码免费专区| 丰满少妇作爱视频免费观看| 亚洲熟妇AV一区二区三区宅男| 亚洲色图在线播放| 亚洲色大成网站www永久一区| 国产高清在线精品免费软件| 思思re热免费精品视频66 | 毛片a级毛片免费观看免下载| 黄色片免费在线观看| sss在线观看免费高清| 亚洲AV成人一区二区三区观看| 亚洲国产精品成人精品小说| 亚洲av午夜福利精品一区人妖|