javax.swing.JOptionPane で showMessageDialog() や showConfirmDialog() を呼び出して表示させたメッセージダイアログのフォントを、 JOptionPane.setFont(Font font) とかで変更できないときの方法。もしくは、Swing でデフォルトのフォントを変更してしまう方法。
UIManager.put("OptionPane.buttonFont", font); UIManager.put("OptionPane.font", font); UIManager.put("OptionPane.messageFont", font);
力業。デフォルトのフォントを変更することになるので、他のダイアログも影響を受ける。
UIManagerで、 UIManager.getDefaults().keys() を呼び出して得られる key の Enumeration を回して、 UIManager.get(key) で得られる Object value が instanceof java.awt.Font なら、 UIManager.put(key.toString(), font) とかやると、強引で素敵。
ソースで書くとこんな感じ。
Font font = new Font(hoge,hoge,hoge);
Enumeration<Object> enumeration = UIManager.getDefaults().keys();
while(enumeration.hasMoreElements()){Object key = enumeration.nextElement();}
Object value = UIManager.get(key);
if (value instanceof java.awt.Font){UIManager.put(key.toString(), font);}
Windows環境であることを確認した上で、"MS UI Gothic"に統一すると、ノスタルジックで良い。
![テストデータ生成なら疑似個人情報ジェネレータ!! [広告] テストデータ生成なら疑似個人情報ジェネレータ!! (People to People Communications 株式会社)](http://www.start-ppd.jp/ad_for_ringoon_head_left.gif)
![疑似個人情報ジェネレータで個人情報漏洩対策!! [広告] 疑似個人情報ジェネレータで個人情報漏洩対策!! (People to People Communications 株式会社)](http://www.start-ppd.jp/ad_for_ringoon_head_right.gif)
            
          
        ![[広告] IL MILIONE ~世界の風景100撰~ 特大サイズ壁紙集 (People to People Communications 株式会社) [広告] IL MILIONE ~世界の風景100撰~ 特大サイズ壁紙集 (People to People Communications 株式会社)](http://image.ringoon.jp/IM01_ad_250x120.jpg)
コメントする
コメントしても反応がない場合は、気が付いてないだけですので、Twitterなどでつっついてください。