🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #885

Re: On java.io.NotSerializableException: java.lang.Object

#885
From: Worm Online
Date: Tue, 23 Jul 2002 08:08
83 lines
3751 bytes
Thank you.

  I have try to out put the RTF document by using the following code:

    XMLEncoder xmle = new XMLEncoder(
                                 new BufferedOutputStream(
                                     new FileOutputStream("test.xml")));
    xmle.writeObject(new JTextPane((DefaultStyledDocument)
m_monitor.getStyledDocument()) );
    xmle.flush();
    xmle.close();

Notice:
 m_monitor is a defined JTextPane.

   If I write 1234 on the JTextPane by using Bold Font, the out put xml file
will be

    <?xml version="1.0" encoding="UTF-8" ?>
-     <java version="1.4.0_01" class="java.beans.XMLDecoder">
-     <object class="javax.swing.JTextPane">
-     <void property="text">
      <string>1234</string>
      </void>
      </object>
      </java>

  if I insert a gif into the JTextPane, the out put xml file will be:

    <?xml version="1.0" encoding="UTF-8" ?>
-     <java version="1.4.0_01" class="java.beans.XMLDecoder">
-     <object class="javax.swing.JTextPane">
-     <void property="text">
      <string />
      </void>
      </object>
      </java>

I meet several problem:
1.  The first problem is the Bold font inofrmation and Gif were lost, could
you tell me what is wrong with the code?

2. As the code above : xmle.writeObject(new
JTextPane((DefaultStyledDocument) m_monitor.getStyledDocument()) );
   if I change it to xmle.writeObject( m_monitor.getStyledDocument() );
   the out put xml file is
      <?xml version="1.0" encoding="UTF-8" ?>
-     <java version="1.4.0_01" class="java.beans.XMLDecoder">
-     <object class="javax.swing.text.DefaultStyledDocument">
-     <void property="documentProperties">
-     <void method="put">
      <object class="java.awt.font.TextAttribute" field="RUN_DIRECTION" />
      <boolean>false</boolean>
      </void>
      </void>
      </object>
      </java>
     the content in the JTextPane disappear, why?

   Thank you for John McGrath and Greetz, Rob.




"John McGrath [TeamB]" <ng-b@JPMcGrath.net> д����Ϣ����
:MPG.1797d02b68cb68e498b820@newsgroups.borland.com...
> On Tue, 9 Jul 2002 18:04:40 +0800, Worm Online wrote:
>
> > And as you said "They have added a new XML based mechanism in
> > Java 1.4 to replace it" , could you tell me that it can work
> > now? If true, point me a way, where to start.
>
> The new mechanism is in the java.beans package.  See the XMLEncoder
> and XMLDecoder classes.
>
> --
> Regards,
>
> John McGrath [TeamB]
>
> ---------------------------------------------------
> Before sending me e-mail, please read:
>     http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID: <3d3d0e9b_2@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-04!supernews.com!news.maxwell.syr.edu!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!dnews
References: <3d2941ad_1@dnews> <MPG.17937befbecfabdc98b7fe@newsgroups.borland.com> <3d2ab537$1_1@dnews> <MPG.1797d02b68cb68e498b820@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 1089d0,37aa6d68d3c616d
X-Google-Attributes: gid1089d0,public
X-Google-ArrivalTime: 2002-07-23 01:12:23 PST
Reply-To: "Worm Online" <worm_online@263.net>
From: "Worm Online" <worm_online@263.net>
Newsgroups: borland.public.jbuilder.java.api
References: <3d2941ad_1@dnews> <MPG.17937befbecfabdc98b7fe@newsgroups.borland.com> <3d2ab537$1_1@dnews> <MPG.1797d02b68cb68e498b820@newsgroups.borland.com>
Subject: Re: On java.io.NotSerializableException: java.lang.Object
Date: Tue, 23 Jul 2002 16:08:40 +0800
Lines: 85
Organization: Southeast Univesity
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Host: 218.2.178.28
Message-ID: <3d3d0e9b_2@dnews>
X-Trace: dnews 1027411611 218.2.178.28 (23 Jul 2002 01:06:51 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-04!supernews.com!news.maxwell.syr.edu!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!dnews