• Post Reply Bookmark Topic Watch Topic
  • New Topic

save with JFileChooser

 
Michaela Fricker
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote an applet, which saves the content of an JTextPane as an RTF-File. (JFileChosser with FileFilter ".rtf"!)
My Problem now is that if you choose an existing RTF-File everything works fine, but if you want to save an new one, there is no .rtf ending. Is there any existing functionality or do I have to wirte my own code?
Thanks...
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you use the save functionallity of JFileChooser, you typically have to write your own save mehtod. There is no way for JFileChooser to know how to save every type of file. So when you click the save button, you just have to call a method that saves your text. So when you create a File file = new File("mydoc.rtf") is where you may add the extension of rtf.
Now, as far as getting the format of an rtf document and saving that, I don't know. I don't think that simply doing a getText() on the TextPane and then grabbing each line and saving that to a file will save it as a true Rich Text Formatted file. Maybe someone else knows.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!