日期:2014-05-20 浏览次数:20713 次
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(); } }