• Post Reply Bookmark Topic Watch Topic
  • New Topic

Loading .rtf file into a JTextPane  RSS feed

 
Cameron Miller
Greenhorn
Posts: 13
Chrome Eclipse IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have looked about and can't find anything that is working. Can anyone help me. I have a JTextPane called textPane and a method which is called to load the file. I have written other methods to make sure the file exists, is the right extension, etc. I need to load the rtf file into the JTextPane

 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'd use a javax.swing.text.rtf.RTFEditorKit, somewhat like
 
Cameron Miller
Greenhorn
Posts: 13
Chrome Eclipse IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It does not allow me to edit the text when i load it in. And there are big gaps between the text.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that class is buggy, and hasn't been touched in years. If it can't handle the RTF files you have then you're probably out of luck as far as the built-in stuff goes. There may be 3rd party components, either open source or commercial, that do a better job at displaying RTF. Maybe http://java-sl.com/advanced_rtf_editor_kit.html helps.
 
Cameron Miller
Greenhorn
Posts: 13
Chrome Eclipse IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have used the class you linked. This is my method.



And i have changed the styled document to an AdvancedRTFDocument (came in the downloaded package).


I can edit the text but i still have big gaps in between each line. Any ideas.
Thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!