HashMap<TextAttribute, Object> hm = new HashMap<TextAttribute, Object>(); hm.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); // 定義是否有下划線 hm.put(TextAttribute.SIZE, 12); // 定義字號 hm.put(TextAttribute.FAMILY, "Simsun"); // 定義字體名 Font font = new Font(hm); // 生成字號為12,字體為宋體,字形帶有下划線的字體