43 import java.security.*;
44 import sun.awt.AWTAccessor;
45
46 /**
47 * An implementation of the Icon interface that paints Icons
48 * from Images. Images that are created from a URL, filename or byte array
49 * are preloaded using MediaTracker to monitor the loaded state
50 * of the image.
51 *
52 * <p>
53 * For further information and examples of using image icons, see
54 * <a href="https://docs.oracle.com/javase/tutorial/uiswing/components/icon.html">How to Use Icons</a>
55 * in <em>The Java Tutorial.</em>
56 *
57 * <p>
58 * <strong>Warning:</strong>
59 * Serialized objects of this class will not be compatible with
60 * future Swing releases. The current serialization support is
61 * appropriate for short term storage or RMI between applications running
62 * the same version of Swing. As of 1.4, support for long term storage
63 * of all JavaBeans™
64 * has been added to the <code>java.beans</code> package.
65 * Please see {@link java.beans.XMLEncoder}.
66 *
67 * @author Jeff Dinkins
68 * @author Lynn Monsanto
69 * @since 1.2
70 */
71 @SuppressWarnings("serial") // Same-version serialization only
72 public class ImageIcon implements Icon, Serializable, Accessible {
73 /* Keep references to the filename and location so that
74 * alternate persistence schemes have the option to archive
75 * images symbolically rather than including the image data
76 * in the archive.
77 */
78 private transient String filename;
79 private transient URL location;
80
81 transient Image image;
82 transient int loadStatus = 0;
83 ImageObserver imageObserver;
570 @BeanProperty(expert = true, description
571 = "The AccessibleContext associated with this ImageIcon.")
572 public AccessibleContext getAccessibleContext() {
573 if (accessibleContext == null) {
574 accessibleContext = new AccessibleImageIcon();
575 }
576 return accessibleContext;
577 }
578
579 /**
580 * This class implements accessibility support for the
581 * <code>ImageIcon</code> class. It provides an implementation of the
582 * Java Accessibility API appropriate to image icon user-interface
583 * elements.
584 * <p>
585 * <strong>Warning:</strong>
586 * Serialized objects of this class will not be compatible with
587 * future Swing releases. The current serialization support is
588 * appropriate for short term storage or RMI between applications running
589 * the same version of Swing. As of 1.4, support for long term storage
590 * of all JavaBeans™
591 * has been added to the <code>java.beans</code> package.
592 * Please see {@link java.beans.XMLEncoder}.
593 * @since 1.3
594 */
595 @SuppressWarnings("serial") // Same-version serialization only
596 protected class AccessibleImageIcon extends AccessibleContext
597 implements AccessibleIcon, Serializable {
598
599 /*
600 * AccessibleContest implementation -----------------
601 */
602
603 /**
604 * Gets the role of this object.
605 *
606 * @return an instance of AccessibleRole describing the role of the
607 * object
608 * @see AccessibleRole
609 */
610 public AccessibleRole getAccessibleRole() {
|
43 import java.security.*;
44 import sun.awt.AWTAccessor;
45
46 /**
47 * An implementation of the Icon interface that paints Icons
48 * from Images. Images that are created from a URL, filename or byte array
49 * are preloaded using MediaTracker to monitor the loaded state
50 * of the image.
51 *
52 * <p>
53 * For further information and examples of using image icons, see
54 * <a href="https://docs.oracle.com/javase/tutorial/uiswing/components/icon.html">How to Use Icons</a>
55 * in <em>The Java Tutorial.</em>
56 *
57 * <p>
58 * <strong>Warning:</strong>
59 * Serialized objects of this class will not be compatible with
60 * future Swing releases. The current serialization support is
61 * appropriate for short term storage or RMI between applications running
62 * the same version of Swing. As of 1.4, support for long term storage
63 * of all JavaBeans
64 * has been added to the <code>java.beans</code> package.
65 * Please see {@link java.beans.XMLEncoder}.
66 *
67 * @author Jeff Dinkins
68 * @author Lynn Monsanto
69 * @since 1.2
70 */
71 @SuppressWarnings("serial") // Same-version serialization only
72 public class ImageIcon implements Icon, Serializable, Accessible {
73 /* Keep references to the filename and location so that
74 * alternate persistence schemes have the option to archive
75 * images symbolically rather than including the image data
76 * in the archive.
77 */
78 private transient String filename;
79 private transient URL location;
80
81 transient Image image;
82 transient int loadStatus = 0;
83 ImageObserver imageObserver;
570 @BeanProperty(expert = true, description
571 = "The AccessibleContext associated with this ImageIcon.")
572 public AccessibleContext getAccessibleContext() {
573 if (accessibleContext == null) {
574 accessibleContext = new AccessibleImageIcon();
575 }
576 return accessibleContext;
577 }
578
579 /**
580 * This class implements accessibility support for the
581 * <code>ImageIcon</code> class. It provides an implementation of the
582 * Java Accessibility API appropriate to image icon user-interface
583 * elements.
584 * <p>
585 * <strong>Warning:</strong>
586 * Serialized objects of this class will not be compatible with
587 * future Swing releases. The current serialization support is
588 * appropriate for short term storage or RMI between applications running
589 * the same version of Swing. As of 1.4, support for long term storage
590 * of all JavaBeans
591 * has been added to the <code>java.beans</code> package.
592 * Please see {@link java.beans.XMLEncoder}.
593 * @since 1.3
594 */
595 @SuppressWarnings("serial") // Same-version serialization only
596 protected class AccessibleImageIcon extends AccessibleContext
597 implements AccessibleIcon, Serializable {
598
599 /*
600 * AccessibleContest implementation -----------------
601 */
602
603 /**
604 * Gets the role of this object.
605 *
606 * @return an instance of AccessibleRole describing the role of the
607 * object
608 * @see AccessibleRole
609 */
610 public AccessibleRole getAccessibleRole() {
|