Posted By:
Ivn_Tcakov
Posted On:
Tuesday, October 14, 2003 04:24 PM
Hello, I am experiencing a new serialization exception. I am not sure if it something subtle that I might have changed in the code or if it is due to a new jdk version, but here it is: I am trying to save the components of my GUI to the hard disk and I want to make new cloned versions of these components. To clone, I am using the 'deep copy' example of doubling an object: static public Object deepCopy(Object oldObj) throws Exception { ObjectOutputStream oos = null; ObjectInputStream ois = null; try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); // A oos = new ObjectOutputStream(bos); // B /
More>>
Hello, I am experiencing a new serialization exception. I am not sure if it something subtle that I might have changed in the code or if it is due to a new jdk version, but here it is:
I am trying to save the components of my GUI to the hard disk and I want to make new cloned versions of these components.
To clone, I am using the 'deep copy' example of doubling an object:
static public Object deepCopy(Object oldObj) throws Exception
{
ObjectOutputStream oos = null;
ObjectInputStream ois = null;
try
{
ByteArrayOutputStream bos =
new ByteArrayOutputStream(); // A
oos = new ObjectOutputStream(bos); // B
// serialize and pass the object
oos.writeObject(oldObj); // C
oos.flush(); // D
ByteArrayInputStream bin =
new ByteArrayInputStream(bos.toByteArray()); // E
ois = new ObjectInputStream(bin); // F
// return the new object
return ois.readObject(); // G
}
catch(Exception e)
{
System.out.println("Exception in ObjectCloner = " + e);
throw(e);
}
So when I try to perform this method on a few objects (java.awt.CheckboxGroup, java.awt.Choice
java.awt.List), it gives me an exception about a class that I don't really know where and what it is:
java.io.NotSerializableException: java.awt.TexturePaint
All of the components that I tried to do deepcopy do implement 'Serializeable' Interface so. I don't understand what this exception means.
I would appreciate any comments or suggestions, thanks
Ivan
<<Less