我试图在JTextPane中显示RTF文件的文本,它只显示纯文本,但我需要带有粗体,字体,大小等的格式化文本...
这是代码:
public void mostraRTF() {
RTFEditorKit rtf = new RTFEditorKit();
rtfDisplay.setEditorKit( rtf );
rtfDisplay.setBackground( Color.white );
try {
FileInputStream fi = new FileInputStream( "F:\\31012200.rtf" );
rtf.read( fi, rtfDisplay.getDocument(), 0 );
}
catch( FileNotFoundException e )
{
System.out.println( "File not found" );
}
catch( IOException e )
{
System.out.println( "I/O error" );
}
catch( BadLocationException e )
{
}
}