使用new前确保已经执行。
最好使用静态代码方式执行
static{
  UIManager.put("JButton.font",font");
}

解决方案 »

  1.   

    Font f=new FontUIResource("Arial",Font.PLAIN,20);
    UIManager.put("Button.font",f);
    UIManager.put("Label.font",f);
    SwingUtilities.updateComponentTreeUI(this);最好写 Button.font 别写 JButton ,即使你用了 Swing
    我也试过好久
      

  2.   

    UIManager.put是针对awt的,所以如楼上所说
    UIManager.put("JButton.font",f);
    -->
    UIManager.put("Button.font",f);
    不过在这里建议使用
    UIManager.put("Button.font",new javax.swing.plaf.FontUIResource(f));