• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic


Richard West
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I am currently trying to serialize parts of a jtextpane using the java ObjectOutputStream to write it to disk and when i am reading the object back i am using the java ObjectInputStream.

When i read the api about the streams here is what they say

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see XMLEncoder.

After reading this i decided to serialize my jtextpane objects using the above
xml format but could not get it to work

I am providing a ruunable example so you guys can compile the source code and see what i mean

When i insert an icon put in some styled text and change the background color of the jtextpane the file is written to disk with no exceptions
but when i try to read back the same file only the previously background color is reloaded but the styled text and embedded icon are gone.

The thing is when i replace both the XMLEncoder and XMLDecoder with
ObjectOutputStream and ObjectInputStream respectively everything works fine.

I don't know why can't serialize objects of my jtextpane but am i missing something.

I hope someone can help me with this problem

Thank You

Yours Sincerely

Richard West
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic