Results 1 to 7 of 7
- 04-14-2011, 02:50 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 8
- Rep Power
- 0
RTF (rich text format) Formatting
Ok I have a text editor that I have made and it bolds underlines etc. but whenever I go to save it, it doesn't format it to bold etc... Do you have any tips for formatting? I opened some RTF in regular notepad and notepad ++ to see the formating but that stuff looks to complicated surely there must be another way?
- 04-15-2011, 06:20 PM #2
Senior Member
- Join Date
- Jan 2009
- Posts
- 671
- Rep Power
- 5
Are you using javax.swing.text.rtf.RTFEditorKit ? If so, you might consider using a different EditorKit. There is a caveat in the API for RTF that states it supports only limited functionality.
- 04-18-2011, 09:38 PM #3
Member
- Join Date
- Mar 2011
- Posts
- 8
- Rep Power
- 0
- 04-18-2011, 10:41 PM #4
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
RTFEditor kit. Im guessing you are using a JTextPane, what is the editor kit you are using on this textpane? I am working on a text editor as well, which uses a JTextPane, and a RTFEditorKit. The editor kit is helpful because it allows you to save and load. We will need more information. Mainly, what the editor kit is, and how saving and loading is accomplished.
- 04-19-2011, 04:28 AM #5
Senior Member
- Join Date
- Jan 2009
- Posts
- 671
- Rep Power
- 5
The editor kits allow you to load, save, display, and edit text of various kinds. If you have written a home grown editor independent of the editor kit API, you could still use the editor kit to save data into RTF format. Take a look at the javax.swing.text.rtf.RTFEditorKit API. It has limited functionality, but it sounds like limited functionality is more than what you currently have, and it would save you a heck of a lot of time trying to format and parse RTF yourself.
- 04-19-2011, 04:06 PM #6
Member
- Join Date
- Mar 2011
- Posts
- 8
- Rep Power
- 0
I am using no rtf editor... I'm using textpane. Currently there is only saving. All it does is write the text to a .rtf ..... so yeah...
- 04-19-2011, 11:43 PM #7
Senior Member
- Join Date
- Jan 2009
- Posts
- 671
- Rep Power
- 5
Ok. If you use a javax.swing.JEditorPane instead of a textpane, you can create one that already has RTF hooks in it.
If you're using a JTextPane, you can try creating a standalone RTFEditorKit and call 'getDocument' on your JTextPane to get the Document you need to pass to the 'write' method of the RTFEditorKit.Java Code:JEditorPane editorPane = new JEditorPane("text/rtf"); ... editorPane.getEditorKit().write(editorPane.getDocument());
Similar Threads
-
Text format in JTextArea
By goodlily in forum AWT / SwingReplies: 4Last Post: 04-10-2011, 11:57 PM -
Text/String format..??
By Neullson in forum New To JavaReplies: 14Last Post: 07-23-2010, 08:51 AM -
Text formatting and alignment according to the printer
By java_fledgeling in forum Advanced JavaReplies: 2Last Post: 06-08-2010, 10:34 AM -
Format some text with Java
By vampire in forum New To JavaReplies: 0Last Post: 02-18-2010, 06:45 AM -
[SOLVED] *Simple* Eclipse Text Formatting Question
By davomyster in forum EclipseReplies: 1Last Post: 03-16-2009, 06:05 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks