jdk/src/java.desktop/share/classes/javax/swing/ImageIcon.java
changeset 26037 508779ce6619
parent 26001 991e1be0b235
parent 25859 3317bb8137f4
child 32865 f9cb6e427f9e
equal deleted inserted replaced
25992:e9b05e933ddd 26037:508779ce6619
   488     }
   488     }
   489 
   489 
   490     private void readObject(ObjectInputStream s)
   490     private void readObject(ObjectInputStream s)
   491         throws ClassNotFoundException, IOException
   491         throws ClassNotFoundException, IOException
   492     {
   492     {
   493         s.defaultReadObject();
   493         ObjectInputStream.GetField f = s.readFields();
       
   494 
       
   495         imageObserver = (ImageObserver) f.get("imageObserver", null);
       
   496         description = (String) f.get("description", null);
       
   497         width = f.get("width", -1);
       
   498         height = f.get("height", -1);
       
   499         accessibleContext = (AccessibleImageIcon) f.get("accessibleContext", null);
   494 
   500 
   495         int w = s.readInt();
   501         int w = s.readInt();
   496         int h = s.readInt();
   502         int h = s.readInt();
   497         int[] pixels = (int[])(s.readObject());
   503         int[] pixels = (int[])(s.readObject());
       
   504 
       
   505         if (pixels == null && (w != -1 || h != -1)) {
       
   506             throw new IllegalStateException("Inconsistent width and height"
       
   507                     + " for null image [" + w + ", " + h + "]");
       
   508         }
       
   509 
       
   510         if (pixels != null && (w < 0 || h < 0)) {
       
   511             throw new IllegalStateException("Inconsistent width and height"
       
   512                     + " for image [" + w + ", " + h + "]");
       
   513         }
       
   514 
       
   515         if (w != getIconWidth() || h != getIconHeight()) {
       
   516             throw new IllegalStateException("Inconsistent width and height"
       
   517                     + " for image [" + w + ", " + h + "]");
       
   518         }
   498 
   519 
   499         if (pixels != null) {
   520         if (pixels != null) {
   500             Toolkit tk = Toolkit.getDefaultToolkit();
   521             Toolkit tk = Toolkit.getDefaultToolkit();
   501             ColorModel cm = ColorModel.getRGBdefault();
   522             ColorModel cm = ColorModel.getRGBdefault();
   502             image = tk.createImage(new MemoryImageSource(w, h, cm, pixels, 0, w));
   523             image = tk.createImage(new MemoryImageSource(w, h, cm, pixels, 0, w));