🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: regaining functionality from save file

#710
From: John McGrath [TeamB]
Date: Thu, 30 Dec 2004 04:47
37 lines
2785 bytes
On 12/29/2004 at 11:23:51 AM, Alan Shiers wrote:

> When I open a saved file, I wound up manually iterating over every
> instance of the TargetPanel(s) and calling installDnD() on each one in
> order to reinstate each TargetPanel as being a viable drop target for
> transferable components.  Is this usual? Wouldn't this functionality be
> saved. I shouldn't have to do that should I?

I can see no reason that you should have to, if serialization worked well
with Swing components.  But there have always been problems with Swing and
serialization, and Sun recommends against using it.  I tried serializing
Swing components back with JDK 1.2 and I quickly gave up on the idea.
Over the years I have seen many people try it, and they all had
significant problems.

There have been members that were marked as transient that held important
state, so that the state was lost when the component was deserialized.
There have also been members that were not marked as transient, but were
not serializable either, so serialization would fail.  In some cases,
these members were only set under specific circumstances, so the
serialization would only fail on occasion - usually after the code was
deployed.

What I have found works very well is to persist the model and to build the
view components from scratch when you launch your program.  You may have a
few view attributes that you want to save, but it is much easier to
persist just those attributes and apply them when you build the UI.  You
will have far fewer problems with this approach.

-- 
Regards,

John McGrath [TeamB]

---------------------------------------------------
Before sending me e-mail, please read:
    http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID: <xn0drloff95sji8000@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!proxad.net!194.117.148.138.MISMATCH!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <41d0409e$1@newsgroups.borland.com> <xn0drjdwa6iyqr9003@newsgroups.borland.com> <41d2db25$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,24838fa202265eb4
X-Google-Attributes: gid111d45,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "John McGrath  [TeamB]" <ng-b@JPMcGrath.net>
Subject: Re: regaining functionality from save file
Newsgroups: borland.public.jbuilder.java.swing
References: <41d0409e$1@newsgroups.borland.com> <xn0drjdwa6iyqr9003@newsgroups.borland.com> <41d2db25$1@newsgroups.borland.com>
User-Agent: XanaNews/1.16.5.2
Message-ID: <xn0drloff95sji8000@newsgroups.borland.com>
X-Ref: newsgroups.borland.com ~XNS:000000CC
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15
NNTP-Posting-Host: 141.158.234.226
Date: 29 Dec 2004 20:47:20 -0800
X-Trace: newsgroups.borland.com 1104382040 141.158.234.226 (29 Dec 2004 20:47:20 -0800)
Lines: 37
X-Authenticated-User: jpmcgrath
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!proxad.net!194.117.148.138.MISMATCH!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail