• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

save with JFileChooser

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic