请教一下:我现在想用UIManager.setLookAndFeel()来设置我的swing外观,如果用motif,metal,system三种自带的则可以正常显示中文,但是我如果用下载的其他的则不能正常显示中文,显示的是小方框.例如我用setLookAndFeel("net.sourceforge.napkinlaf.NapkinLookAndFeel"),之后添加一个(new JButton("你好")),不能正常显示,英文正常.
 请问这个问题怎么解决啊?
非常感谢!

解决方案 »

  1.   

    没遇到过,有可能是你用的LookAndFeel默认字体问题,你给组件重新设置一下字体试试。
      

  2.   

    在后面加上getbytes(encoding),参数encoding是统一程序运行编码,以防止在不同的机器上由于不同的默认编码方式产生乱码问题,具体由utf8,gbk,big5,unicode等
      

  3.   

    找到源码,导入,再找到font,修改之.
      

  4.   

    字体问题。找到该lnf包中的 theme 对象。
    继承需要的theme,重写里头的getFont方法。
    返回字体名为“Dialog”(当然,你使用中文字体:“宋体”....也行,但是兼容性不好)的字体。
      

  5.   

    xywl(xywl) ( ) 信誉:94     
       能说详细点吗?yonghar(ohno) ( ) 信誉:105 
       请问这个Inf包是哪里的包? 下载的那个JAR里面没有这个包那个LookAndFeel JAR的下载地址是:
    http://jaist.dl.sourceforge.net/sourceforge/napkinlaf/napkinlaf-jars-1.0_001.zippublic class TestNapkin extends JFrame {
      public TestNapkin(){
    Container cp = getContentPane();
    cp.setLayout(new FlowLayout());
    cp.add(new JButton("hello"));
    cp.add(new JButton(getChineseOut("你好!")));
      }
      public static void main(String[]args){
        try{
    UIManager.setLookAndFeel("net.sourceforge.napkinlaf.NapkinLookAndFeel");
        }catch(Exception e){}
        TestNapkin frame = new TestNapkin();
        frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
        frame.setSize(300,200);
        frame.setVisible(true);
      }
    }