File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Java JTextPane Save Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Java JTextPane Save" Watch "Java JTextPane Save" New topic
Author

Java JTextPane Save

i kurtz
Greenhorn

Joined: Apr 27, 2010
Posts: 6
i was trying to do some simple text formatting using JEditorPane but then as knowledge grew i found JTextPane easier to implement and more robust.

my query is how do i save the formatted text in JTextPane to file? it should be RTF or HTML or other.. as this file is not opened by the application again.

it is a chat history text file with formatted text and should open as rtf in word or as html in internet explorer.

thank you.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4642
    
    5

Cross posted
http://www.javaprogrammingforums.com/file-i-o-other-i-o-streams/4218-java-jtextpane-save.html
http://stackoverflow.com/questions/2723073/java-jtextpane-save
http://forums.sun.com/thread.jspa?threadID=5437282
http://www.java-forums.org/awt-swing/28259-java-jtextpane-save.html


luck, db
There are no new questions, but there may be new answers.
Preston Taylor
Greenhorn

Joined: Feb 18, 2010
Posts: 7
I have never tried formating as RTF but I have putput formatted HTML text to a file using the properties class and it held all the special characters etc from my text pane. I think that might work for you that way you can use the properties file like "Bill 11:15 PM" = "<HTML>blah blah <p>blah" as far as I know Properties works with any file extension. it just outputs straight text to whatever file you give it. This may not work easily if you just want plain text output (just out put your html tags etc as plain text it's fairly easy) use something like this:

CODE COPIED FROM JAVA2S.COM

keep in mind you can change that file extension to whatever you want. it doesn't have to be txt.


When in doubt google!
btw Java2s.com is a great site for noobs that need examples
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19720
    
  20

I. Kurz, please Be Forthright When Cross Posting To Other Sites.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
i kurtz
Greenhorn

Joined: Apr 27, 2010
Posts: 6
i am relatively new at this and i usually wait but regarding this topic i havent recieved any great guidence.

i will keep your tips in mind but i dont see the need for someone trying to hunt my posting down all over the place before providing me with a reason for their flame like postings.

hope you understand.

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19720
    
  20

Darryl doesn't hunt down anyone's posts, he just visits a lot of Java boards. That's why he's often the one to find these kinds of cross posts. And where did you see any flaming?
i kurtz
Greenhorn

Joined: Apr 27, 2010
Posts: 6
i said: flame like postings.... not actual flame.

it is the style and tone of reporting not the reporting itself.

he should have asked for an explanation politely instead of just mentioning cross post this and that.

nuff said.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2203
    
    7
but regarding this topic i havent recieved any great guidence.


You received the same suggestion in at least two different forums from two different people. I would call that great guidance.

Nowhere in any of your mulitple postings (that I have read) have you replied back stating what you do or don't understand.

hope you understand.


You should be understanding it from out point of view. We only have limited time to help people and would rather not spend it repeating answers that have been given elsewhere, when we could be helping others instead.
i kurtz
Greenhorn

Joined: Apr 27, 2010
Posts: 6
your view and my view differs.

the responses i have recieved so far are not suitable at present. this means im searching the web based on their tips and once i have made progress i hope to move on.

but strangly enough im havent made much progress so i posted across other forums also.

that is all that happened.

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18662
    
    8

i kurtz wrote:this means im searching the web based on their tips and once i have made progress i hope to move on.

but strangly enough im havent made much progress so i posted across other forums also.


Actually it doesn't look like that. To me it just looks like you posted the identical question in four different places. There's no evidence that you considered the answers on one forum and then posted better questions elsewhere based on those answers.

However now that it's all in the open, it's no problem. Or are there other cross-posts of the question elsewhere which you need to tell us about?
i kurtz
Greenhorn

Joined: Apr 27, 2010
Posts: 6
no thats about it regarding posting.

i did not know i had to document everything when i ask a question in a forum before. i doubt that is the case for anyone.

im still searching the web but the threads of thought are not becoming interlinked like they usually do.. thats why the expansion..

any way.. i think we should quit now as both of our precious time could be invested better with other issues i.e. important ones.

thanks.
i kurtz
Greenhorn

Joined: Apr 27, 2010
Posts: 6
http://www.javaprogrammingforums.com/file-i-o-other-i-o-streams/4218-java-jtextpane-save.html#post11565

sorry for the multiple posting.. was too stressed out! solution above.

glad i understood it.. took drastic limits to understand the solution but i managed it.

thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java JTextPane Save