JDK-4855652 : Make javax.swing.Spring and javax.swing.SpringLayout.Constraints serializable
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2003-04-29
  • Updated: 2003-05-09
  • Resolved: 2003-05-09
Related Reports
Duplicate :  
Description

Name: jl125535			Date: 04/29/2003


A DESCRIPTION OF THE REQUEST :
javax.swing.Spring and javax.swing.SpringLayout.Constraints should implement Serializable.

JUSTIFICATION :
What I need to do is create a JFrame with Swing components
inside (JPanel's, JLabel's, etc.), to save it as an XML file
and be able to restore it later. As of JDK 1.4, I use the
pair XMLEncoder/XMLDecoder to manage the serialization.
For various reasons, the most appropriate layout manager for
my application is SpringLayout. When defining a SpringLayout
as layout manager for a panel, this property was transferred
to the XML by XMLEncoder and restored by XMLDecoder (as the
class implements Serializable).

But then, the happy days are over! In order for a
SpringLayout to work, one must obviously define lots of
SpringLayout.Constraints, using Springs. But none of these
things are transferred by XMLEncoder to the XML.
And, quite naturally, even if I modify manually the XML to
include some constraint info, the XMLDecoder won't read that
info!

The problem is that the two classes (i.e.,
javax.swing.Spring and javax.swing.SpringLayout.Constraints)
are not implementing Serializable.

CUSTOMER WORKAROUND :
Extend Spring and SpringLayout.Constraints in order to implement Serializable.  (I have not confirmed this approach.)
(Review ID: 147206) 
======================================================================

Comments
EVALUATION The two Spring classes do not have to implement Serializable to use the XML persistence. I believe the submitter stubled accross bug 4679556. Which as been fixed in 1.4.2. Please try the 1.4.2-beta. If your problem is still here, please resubmit the bug with a reproducible test case. ###@###.### 2003-05-09
09-05-2003