home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-18 | 1.8 KB | 61 lines |
- package symantec.itools.multimedia;
-
- import java.net.URL;
- import java.awt.Image;
- import java.io.ObjectInputStream;
- import java.io.IOException;
- import java.awt.MediaTracker;
- import java.awt.Component;
- import java.util.ResourceBundle;
- import java.text.MessageFormat;
-
- // 05/30/97 RKM Moved AnimatorImage class into its own file as the compiler suggested
- // 07/15/97 CAR added a default constructor and a constructor which takes a component reference
- // added a Component reference field and marked fields transient as needed
- // implemented the Serializable interface
- // implemented readObject to load the images of the deserialized URLs
-
- class AnimatorImage implements java.io.Serializable
- {
- URL url;
- transient Image image;
- transient boolean loaded;
- Component comp = null;
-
- transient protected ResourceBundle errors;
-
- public AnimatorImage() { }
-
- public AnimatorImage(URL u, Image i, boolean l, Component c) {
- this(u, i, l);
- comp = c;
- }
-
- public AnimatorImage(URL u, Image i, boolean l)
- {
- url = u;
- image = i;
- loaded = l;
- }
-
- private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
- stream.defaultReadObject();
-
- errors = ResourceBundle.getBundle("symantec.itools.resources.ErrorsBundle");
-
- image = comp.getToolkit().getImage(url);
-
- MediaTracker tracker = new MediaTracker(comp);
- tracker.addImage(image, 0);
- try {
- tracker.waitForAll();
- }
- catch(InterruptedException e) {
- Object[] args = { url };
- throw new IOException(MessageFormat.format(errors.getString("ErrorLoadingImageForURL"), args));
- }
-
- loaded = true;
- }
- }
-