1 19 20 package org.lucane.client.util; 21 22 import java.awt.*; 23 import java.io.FileInputStream ; 24 import java.io.FileNotFoundException ; 25 import java.io.IOException ; 26 27 import javax.swing.UIManager ; 28 import javax.swing.plaf.FontUIResource ; 29 30 public class FontManager 31 { 32 public static void setDefaultFont(Font font){ 33 Font bold12 = font.deriveFont(Font.BOLD, 12); 34 Font plain12 = font.deriveFont(Font.PLAIN, 12); 35 Font plain10 = font.deriveFont(Font.PLAIN, 10); 36 37 String [] properties = new String []{"Button.font", "CheckBox.font", 39 "CheckBoxMenuItem.font", "ComboBox.font", 40 "DesktopIcon.font", "InternalFrame.font", 41 "Label.font", "Menu.font ", 42 "MenuBar.font", "MenuItem.font", 43 "ProgressBar.font", "RadioButton.font", 44 "RadioButtonMenuItem.font", "TabbedPane.font", 45 "TitledBorder.font", "ToggleButton.font", "ToolBar.font"}; 46 for(int i=0;i<properties.length;i++) 47 UIManager.put(properties[i], new FontUIResource (bold12)); 48 49 properties = new String []{"ColorChooser.font", "EditorPane.font", 51 "List.font", "OptionPane.font", 52 "Panel.font", "PasswordField.font", 53 "PopupMenu.font", "ScrollPane.font", 54 "Table.font", "TableHeader.font", 55 "TextArea.font", "TextField.font", 56 "TextPane.font", "ToolTip.font", 57 "Tree.font", "Viewport.font"}; 58 for(int i=0;i<properties.length;i++) 59 UIManager.put(properties[i], new FontUIResource (plain12)); 60 61 properties = new String []{"Menu.acceleratorFont", 63 "MenuItem.acceleratorFont", "RadioButtonMenuItem.acceleratorFont"}; 64 for(int i=0;i<properties.length;i++) 65 UIManager.put(properties[i], new FontUIResource (plain10)); 66 } 67 68 public static void setDefaultFont(String fileName) 69 throws FileNotFoundException , FontFormatException, IOException 70 { 71 Font font = Font.createFont(Font.TRUETYPE_FONT, new FileInputStream (fileName)); 72 setDefaultFont(font); 73 } 74 } | Popular Tags |