简体   繁体   中英

Writing simple RTF files in Java

I am using Java 6, Windows XP, Eclipce Java EE IDE Juno, Swing. Im looking for the simplest solution without adding any new librarys. To describe my question i will first start with describing my goal.

My idea is to print out in the following format:


Heading

subHeading

stuffs stuffs stuffs stuffs stuffs stuffs


I would like to get to this goal by using RTF file format. What i have concluded is that i should probably use JEditorPane and some how add line by line formated text into the editor. After im done i would like to write the JEditorPane to file and save it.

So, that said. There are some questionmarks here i do not seem to figure out.

What "standard" class can i use to create RTF formated string lines? Is JEditorPane the best container for a RTF document?

Thanks for your time!

The documentation has everything you need. ( http://goo.gl/EJSpx )

  • Create javax.swing.text.rtf.RTFEditorKit by calling createEditorKitForContentType
  • Add newly created editorkit to JEditorPane by calling registerEditorKitForContentType (notice that support for RTF is limited)

Hope this put you on the right path.

See this thread as well Can anyone recommend a Java rich text editor?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM