<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技巧. 設置全局字體[zz]

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

    Swing技巧. 設置全局字體

    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); 

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

    Feedback

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

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

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

    ok, i see  回復  更多評論   

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

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

    //設置全局字體
    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));

    }
    }

    主站蜘蛛池模板: 毛片免费全部播放一级| 免费a级毛片高清视频不卡| 91精品国产免费| 免费黄色小视频网站| 亚洲av之男人的天堂网站| 国产亚洲欧美在线观看| 黄+色+性+人免费| 国产亚洲3p无码一区二区| 无码天堂va亚洲va在线va| 亚洲热妇无码AV在线播放| 特级aa**毛片免费观看| 在线v片免费观看视频| 亚洲日产2021三区| 最新久久免费视频| 免费一级特黄特色大片在线| 亚洲va久久久久| 在线视频精品免费| 成年网站免费入口在线观看 | 波多野结衣中文字幕免费视频| 亚洲五月丁香综合视频| 精品国产sm捆绑最大网免费站| 亚洲美女在线观看播放| 暖暖免费日本在线中文| 久久久久亚洲av无码专区蜜芽| 久久久受www免费人成| 久久国产成人亚洲精品影院 | 亚洲精品无码Av人在线观看国产| 台湾一级毛片永久免费| 香蕉大伊亚洲人在线观看| 亚洲国产美女精品久久久久∴| 成人黄软件网18免费下载成人黄18免费视频 | 免费观看大片毛片| 91精品全国免费观看含羞草| 免费中文字幕视频| 亚洲精品成人片在线播放 | 亚洲日韩中文字幕天堂不卡| 中文字幕亚洲日韩无线码| 成年女人免费v片| 最近免费中文字幕高清大全 | 黄色免费在线网址| 在线精品亚洲一区二区|