Java tutorial
/* * Copyright (c) 2003- Shinji Kashihara. All rights reserved. * This program are made available under the terms of the Common Public License * v1.0 which accompanies this distribution, and is available at cpl-v10.html. */ package mergedoc; import java.awt.Font; import java.awt.Toolkit; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.plaf.FontUIResource; import mergedoc.ui.MergeDocFrame; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * ?? * @author Shinji Kashihara */ public class Application { /** */ private static final Log log = LogFactory.getLog(Application.class); /** * ?? * @param args */ public static void main(String[] args) { // ? Look & Feel try { initSystemLookAndFeel(); } catch (Exception e) { log.warn("Look & Feel ??????", e); } // ? new MergeDocFrame(); } /** * ? Look & Feel ??? * @throws ClassNotFoundException LookAndFeel ???????? * @throws InstantiationException ???????????? * @throws IllegalAccessException ???????????? * @throws UnsupportedLookAndFeelException lnf.isSupportedLookAndFeel() ? false ?? */ private static void initSystemLookAndFeel() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); Toolkit.getDefaultToolkit().setDynamicLayout(true); // Windows ??? String osName = System.getProperty("os.name", ""); if (osName.indexOf("Windows") != -1) { Object propoFont = new FontUIResource("MS UI Gothic", Font.PLAIN, 12); Object fixedFont = new FontUIResource("MS Gothic", Font.PLAIN, 12); // ?????????? // ????? instanceof FontUIResource ? // ???UIDefaults ? Lazy Value ?????? for (Object keyObj : UIManager.getLookAndFeelDefaults().keySet()) { String key = keyObj.toString(); if (key.endsWith("font") || key.endsWith("Font")) { UIManager.put(key, propoFont); } } // ????? UIManager.put("OptionPane.messageFont", fixedFont); UIManager.put("TextPane.font", fixedFont); UIManager.put("TextArea.font", fixedFont); } } }