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

    }
    }

    主站蜘蛛池模板: GOGOGO免费观看国语| 亚洲一卡一卡二新区无人区| 成人精品综合免费视频| 又粗又硬又黄又爽的免费视频| 亚洲国产成人手机在线观看| 午夜精品在线免费观看| 久久亚洲AV成人无码国产电影 | 国产午夜精品久久久久免费视| 久久亚洲国产精品123区| 免费福利在线观看| 国产亚洲精品国看不卡| 久久99久久成人免费播放| 九月丁香婷婷亚洲综合色| 337p日本欧洲亚洲大胆裸体艺术| 一级a性色生活片久久无少妇一级婬片免费放 | 久久一本岛在免费线观看2020| 亚洲精品私拍国产福利在线| 2021在线永久免费视频| 波多野结衣亚洲一级| 日韩高清免费在线观看| 色多多www视频在线观看免费| 狠狠综合久久综合88亚洲| 久久免费福利视频| 亚洲欧洲AV无码专区| 亚洲乱码中文字幕手机在线| 一个人看的www免费视频在线观看| 久久久久亚洲AV无码麻豆| 久久久WWW免费人成精品| 亚洲av午夜福利精品一区| 最近中文字幕免费mv在线视频| 亚洲欧洲日本在线观看| 亚洲AV无码一区二三区| 免费国产99久久久香蕉| 亚洲一区二区三区久久久久| 亚洲免费视频网站| 亚洲欧美黑人猛交群| 国产亚洲精品影视在线产品| 5555在线播放免费播放| 视频一区在线免费观看| 亚洲一区二区三区四区在线观看| 在线观看人成视频免费|