如题:
用word新建一个空文档,输入一排英中文混排的文字,另存为rtf文件:c:\test.rtf。
JEditorPane jEditorPane1 = new JEditorPane(); 
jEditorPane1.setContentType("text/rtf"); 
File file = new File ("c:/test.rtf");
String str = file.getAbsolutePath();
str = "file:"+str;
jEditorPane1.setPage(str);
jEditorPane1.setEditable(false);
JFrame jframe = new JFrame("test");
jframe.setContentPane(jEditorPane1);
jframe.setBounds(0,0,100,100);
jframe.setVisible(true);显示出来的英文字符正确,中文乱码。

解决方案 »

  1.   

    出现乱码啊,应该是字符集的问题.你设置一下encode,比如设置成utf-8
      

  2.   

    在哪设呢?试过了:jEditorPane1.setContentType("text/rtf;charset=gb2312"); 效果一样的
      

  3.   

    this.richTextBox1.Rtf = @"{\rtf1\ansi\ansicpg936 dajiahao: 13:11:40"+ @"\par    文章 }";这个rtf可以正常显示中文