Java: Swing里怎样给界面设置一致的字体

Java: Swing里怎样给界面设置一致的字体
    
    
    
    
import java.awt.Font; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.UIManager; @SuppressWarnings( " serial " ) public class FontTestFrame extends JFrame { public FontTestFrame() { this .setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menubar = new JMenuBar(); JMenu m = new JMenu( " 文件 " ); m.add( new JMenuItem( " 打开 " )); menubar.add(m); this .setJMenuBar(menubar); this .add( new JButton( " 测试 " )); this .pack(); this .setVisible( true ); } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Font font = new Font( " 宋体 " ,Font.PLAIN, 15 ); UIManager.put( " Button.font " , font); UIManager.put( " Menu.font " , font); UIManager.put( " MenuItem.font " , font); new FontTestFrame(); } }
原文出处: http://topic.csdn.net/u/20090614/18/f693c570-7139-425e-ad37-c4406c9fda62.html?87253

你可能感兴趣的:(Java: Swing里怎样给界面设置一致的字体)