Advanced RTFEditorKit library in JEditorPane/JTextPane.
Default RTFEditorKit from JDK provided by SUN has restricted functionality. Features like paragraph attributes, images and tables just aren't supported. The library is an attempt to provide missing functionality.
The Advanced RTFEditorKit supports MS Word 2000 compatible rtf format. Following features:
The AdvancedRTFEditorKit screenshot shows how it looks:
To show RTF file in JEditorPane use following code:
JEditorPane editorPane=new JEditorPane(); editorPane.setEditorKit(new AdvancedRTFEditorKit()); editorPane.read(new FileInputStream(pathToRTFFile)); //or String rtfString=null; //some code to init the string editorPane.setText(rtfString);
The kit is free to use as is but the source code isn't free. If you need the AdvancedRTFEditorKit source code to use or change please contact me.