字体的问题已经解决了,通过下面的方法:
Font f=new Font("宋体",Font.PLAIN,12);
UIManager.put("Label.font",f);
UIManager.put("ComboBox.font",f);
UIManager.put("Button.font",f);
UIManager.put("TabbedPane.font",f);
UIManager.put("RadioButton.font",f);
UIManager.put("TitledBorder.font",f);
现在的问题是我如何把他的提示和按纽上的字体变成英文的啊?

解决方案 »

  1.   

    you should set Locale to ENGLISH. check the Locale class
      

  2.   

    原来看到过改字体的方法,但是默认中文变英文不知道了。up!
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.plaf.*;
    public class test
    {
       public static void setUIFont (javax.swing.plaf.FontUIResource f)
       {
           java.util.Enumeration keys = UIManager.getDefaults().keys();
           while (keys.hasMoreElements())
           {
               Object key = keys.nextElement();
               Object value = UIManager.get (key);
               if (value instanceof javax.swing.plaf.FontUIResource)
                   UIManager.put (key, f);
           }
       }
       public static void main(String[] args)
       {
          Font myFont=new Font("Serif",Font.ITALIC,18);
          FontUIResource fontRes = new javax.swing.plaf.FontUIResource(myFont);
          setUIFont(fontRes);
          int result = JOptionPane.showConfirmDialog(null,"Are you sure exit?","Exit",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
          if (result == JOptionPane.YES_OPTION )
          {  
            System.out.println("YES");
          }
          else if(result == JOptionPane.NO_OPTION )
          {
            System.out.println("NO");
          }
       }
    }
      

  3.   

    不是根据操作系统的语言,是根据地区设置,Windows在 控制面板->区域设置 里设.