Serializable & Externalizable
Serializing image or image path to image.
The root of the problem is the Image class which cannot be serialized.
I've implemented serializable and what i wan't is to load an image from a path
when the object is de-serialized.
public class Aaaaaa extends Canvas implements Serializable
{
transient Image image;
String pathToImage;
private void writeObject(java.io.ObjectOutputStream out) throws IOException
{
out.writeObject(pathToImage);
}
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException;
{
pathToImage = (String)in.readObject();
// Does'nt work, loadImageFromPath returns the correct Image object but this.image remains unchanged
this.image = loadImageFromPath(pathToImage);
}
public void paint(Graphics..........................
}