πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #9674

Re: Serialization problem with JDK 1.2

#9674
From: Jean-Paul Bouzigues
Date: Mon, 14 Feb 2000 00:00
83 lines
3830 bytes
Hi John,

First of all, thanks a lot for your answer.

Now, I tried this solution:
try {
      ObjectOutputStream out = new ObjectOutputStream( new
BufferedOutputStream(new FileOutputStream(file)) );

      ToolTipManager toolTipManager = ToolTipManager.sharedInstance();

      toolTipManager.unregisterComponent(jCheckBox1);
      toolTipManager.unregisterComponent(jCheckBox2);

      out.writeObject(jCheckBox1.getModel()); // no exception !!!
      out.writeObject(jCheckBox2.getModel()); // no exception !!!

      toolTipManager.registerComponent(jCheckBox1);
      toolTipManager.registerComponent(jCheckBox2);

      out.close();
    }
      catch (IOException e) {
      e.printStackTrace();
    }

The problem is that the JChechBox components become disabled after my code
call !!!

Why have i got this problem?

Thanks a lot for your help.
JPaul.

John P. McGrath a οΏ½crit dans le message ...
>On Thu, 10 Feb 2000 10:37:26 +0100, Jean-Paul Bouzigues wrote:
>
>> Using JDK 1.2, I need to serialize somes JCheckBox components
>> which have associated toolTips. I've got the next message:
>>
>> java.io.NotSerializableException: javax.swing.ToolTipManager
>
>It is never very easy to trace down why the serialization mechanism is
>trying to serialize a particular object.  Obviously, there is a chain of
>non-transient references from the object you serialize explicitly to the
>object in question, but tracing that chain can be difficult.
>
>I have always avoided serializing Swing components.  For starters, any
>such components will not deserialize properly with a new version of the
>JDK.  You will note that the docs for all of the serializable Swing
>components contain the following:
>
>    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. A future release of Swing
>    will provide support for long term persistence.
>
>Some version of that message has been in the Swing docs for quite a
>while, but the original version said:
>
>    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 Swing1.0
>    applications. It will not be possible to load serialized
>    Swing1.0 objects with future releases of Swing.  The JDK1.2
>    release of Swing will be the compatibility baseline for the
>    serialized form of Swing objects.
>
>Obviously, JDK 1.2 has come and gone, and Sun has not quite figured out
>what to do with Swing serialization.  It is a pretty complex problem.
>Given all of the listeners and client properties that can be attached to
>a component, it can be pretty tough to control what is Serialized.
>
>In my code, I have avoided serializing any part of the UI.  I serialized
>the core "model" objects, and re-create the UI when I deserialize them.
>I also store some selected state information from the UI, but never
>serialize the UI objects themselves.
>
>--
>John P. McGrath
><JPMcGrath@fast.net>
><jpm@nscs.fast.net>
Technical Details
Message-ID: <888vqp$hui2@bornews.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <87u04v$c5b1@bornews.borland.com> <MPG.130d6abfe97b8303989786@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 111d45,d2dcd289d922d7d1
X-Google-Attributes: gid111d45,public
From: "Jean-Paul Bouzigues" <jbouzigu@capgemini.fr>
Subject: Re: Serialization problem with JDK 1.2
Date: 2000/02/14
Message-ID: <888vqp$hui2@bornews.borland.com>
X-Deja-AN: 585727846
References: <87u04v$c5b1@bornews.borland.com> <MPG.130d6abfe97b8303989786@forums.borland.com>
Organization: Another Netscape Collabra Server User
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3612.1700
Newsgroups: borland.public.jbuilder.java.swing