Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Saving MetaData of JTextArea

 
tanu dua
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am planing to make a small application having my personal diary.
What I want is to put some text in JTextArea and when the user will click save , it should be stored as encrypted text i.e. before sending to DB ill encrypt that.

But , the question is I want rtf features in my Text i.e bold,italic etc so how to encrypt and decrypt this metadata.

Do I have to use XML for this ?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Swing/AWT
 
John G Martinson
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to use Rich Text Formatting you might want to use JTextPane. It handles that sort of things and a whole lot more.

As for saving the formatting information, you do have the option of using XML. This will require that you figure out/find an XML structure to handle that.

On the other hand, JTextPane implements the serializable interface. This interface allows a class to be put in a linear format so that it can be passed into an io stream and re-instantiated into a working object.

I'm not sure exactly how that works in code, as I have never actaully done it myself, but that would probably be the easiest way to do it.

In the API doc it mentions that there will be compatibility issues from version to version and a better solution to take care of that.

Good luck.
 
tanu dua
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks John , the second option looks good.I am trying to implement this
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic