< prev index next >

src/java.desktop/share/classes/java/awt/Toolkit.java

Print this page




 641      * of the following formats: GIF, JPEG or PNG.
 642      * The underlying toolkit attempts to resolve multiple requests
 643      * with the same URL to the same returned Image.
 644      * <p>
 645      * Since the mechanism required to facilitate this sharing of
 646      * {@code Image} objects may continue to hold onto images
 647      * that are no longer in use for an indefinite period of time,
 648      * developers are encouraged to implement their own caching of
 649      * images by using the {@link #createImage(java.net.URL) createImage}
 650      * variant wherever available.
 651      * If the image data stored at the specified URL changes,
 652      * the {@code Image} object returned from this method may
 653      * still contain stale information which was fetched from the
 654      * URL after a prior call.
 655      * Previously loaded image data can be manually discarded by
 656      * calling the {@link Image#flush flush} method on the
 657      * returned {@code Image}.
 658      * <p>
 659      * This method first checks if there is a security manager installed.
 660      * If so, the method calls the security manager's
 661      * {@code checkPermission} method with the
 662      * url.openConnection().getPermission() permission to ensure
 663      * that the access to the image is allowed. For compatibility



 664      * with pre-1.2 security managers, if the access is denied with
 665      * {@code FilePermission} or {@code SocketPermission},
 666      * the method throws the {@code SecurityException}
 667      * if the corresponding 1.1-style SecurityManager.checkXXX method
 668      * also denies permission.
 669      * @param     url   the URL to use in fetching the pixel data.
 670      * @return    an image which gets its pixel data from
 671      *                         the specified URL.
 672      * @throws SecurityException  if a security manager exists and its
 673      *                            checkPermission method doesn't allow
 674      *                            the operation.
 675      * @see #createImage(java.net.URL)
 676      */
 677     public abstract Image getImage(URL url);
 678 
 679     /**
 680      * Returns an image which gets pixel data from the specified file.
 681      * The returned Image is a new object which will not be shared
 682      * with any other caller of this method or its getImage variant.
 683      * <p>


 685      * If so, the method calls the security manager's
 686      * {@code checkRead} method with the specified file to ensure
 687      * that the image creation is allowed.
 688      * @param     filename   the name of a file containing pixel data
 689      *                         in a recognized file format.
 690      * @return    an image which gets its pixel data from
 691      *                         the specified file.
 692      * @throws SecurityException  if a security manager exists and its
 693      *                            checkRead method doesn't allow the operation.
 694      * @see #getImage(java.lang.String)
 695      */
 696     public abstract Image createImage(String filename);
 697 
 698     /**
 699      * Returns an image which gets pixel data from the specified URL.
 700      * The returned Image is a new object which will not be shared
 701      * with any other caller of this method or its getImage variant.
 702      * <p>
 703      * This method first checks if there is a security manager installed.
 704      * If so, the method calls the security manager's
 705      * {@code checkPermission} method with the
 706      * url.openConnection().getPermission() permission to ensure
 707      * that the image creation is allowed. For compatibility



 708      * with pre-1.2 security managers, if the access is denied with
 709      * {@code FilePermission} or {@code SocketPermission},
 710      * the method throws {@code SecurityException}
 711      * if the corresponding 1.1-style SecurityManager.checkXXX method
 712      * also denies permission.
 713      * @param     url   the URL to use in fetching the pixel data.
 714      * @return    an image which gets its pixel data from
 715      *                         the specified URL.
 716      * @throws SecurityException  if a security manager exists and its
 717      *                            checkPermission method doesn't allow
 718      *                            the operation.
 719      * @see #getImage(java.net.URL)
 720      */
 721     public abstract Image createImage(URL url);
 722 
 723     /**
 724      * Prepares an image for rendering.
 725      * <p>
 726      * If the values of the width and height arguments are both
 727      * {@code -1}, this method prepares the image for rendering




 641      * of the following formats: GIF, JPEG or PNG.
 642      * The underlying toolkit attempts to resolve multiple requests
 643      * with the same URL to the same returned Image.
 644      * <p>
 645      * Since the mechanism required to facilitate this sharing of
 646      * {@code Image} objects may continue to hold onto images
 647      * that are no longer in use for an indefinite period of time,
 648      * developers are encouraged to implement their own caching of
 649      * images by using the {@link #createImage(java.net.URL) createImage}
 650      * variant wherever available.
 651      * If the image data stored at the specified URL changes,
 652      * the {@code Image} object returned from this method may
 653      * still contain stale information which was fetched from the
 654      * URL after a prior call.
 655      * Previously loaded image data can be manually discarded by
 656      * calling the {@link Image#flush flush} method on the
 657      * returned {@code Image}.
 658      * <p>
 659      * This method first checks if there is a security manager installed.
 660      * If so, the method calls the security manager's
 661      * {@code checkPermission} method with the corresponding
 662      * permission to ensure that the access to the image is allowed.
 663      * If access is denied with {@code URLPermission}, the method throws
 664      * a {@code SecurityException} if the SecurityManager.checkPermission
 665      * method also denies a "connect" {@code SocketPermission} to
 666      * the host and port of the specified URL. For compatibility
 667      * with pre-1.2 security managers, if the access is denied with
 668      * {@code FilePermission} or {@code SocketPermission},
 669      * the method throws the {@code SecurityException}
 670      * if the corresponding 1.1-style SecurityManager.checkXXX method
 671      * also denies permission.
 672      * @param     url   the URL to use in fetching the pixel data.
 673      * @return    an image which gets its pixel data from
 674      *                         the specified URL.
 675      * @throws SecurityException  if a security manager exists and its
 676      *                            checkPermission method doesn't allow
 677      *                            the operation.
 678      * @see #createImage(java.net.URL)
 679      */
 680     public abstract Image getImage(URL url);
 681 
 682     /**
 683      * Returns an image which gets pixel data from the specified file.
 684      * The returned Image is a new object which will not be shared
 685      * with any other caller of this method or its getImage variant.
 686      * <p>


 688      * If so, the method calls the security manager's
 689      * {@code checkRead} method with the specified file to ensure
 690      * that the image creation is allowed.
 691      * @param     filename   the name of a file containing pixel data
 692      *                         in a recognized file format.
 693      * @return    an image which gets its pixel data from
 694      *                         the specified file.
 695      * @throws SecurityException  if a security manager exists and its
 696      *                            checkRead method doesn't allow the operation.
 697      * @see #getImage(java.lang.String)
 698      */
 699     public abstract Image createImage(String filename);
 700 
 701     /**
 702      * Returns an image which gets pixel data from the specified URL.
 703      * The returned Image is a new object which will not be shared
 704      * with any other caller of this method or its getImage variant.
 705      * <p>
 706      * This method first checks if there is a security manager installed.
 707      * If so, the method calls the security manager's
 708      * {@code checkPermission} method with the corresponding
 709      * permission to ensure that the image creation is allowed.
 710      * If access is denied with {@code URLPermission}, the method throws
 711      * a {@code SecurityException} if the SecurityManager.checkPermission
 712      * method also denies a "connect" {@code SocketPermission} to
 713      * the host and port of the specified URL. For compatibility
 714      * with pre-1.2 security managers, if the access is denied with
 715      * {@code FilePermission} or {@code SocketPermission},
 716      * the method throws {@code SecurityException}
 717      * if the corresponding 1.1-style SecurityManager.checkXXX method
 718      * also denies permission.
 719      * @param     url   the URL to use in fetching the pixel data.
 720      * @return    an image which gets its pixel data from
 721      *                         the specified URL.
 722      * @throws SecurityException  if a security manager exists and its
 723      *                            checkPermission method doesn't allow
 724      *                            the operation.
 725      * @see #getImage(java.net.URL)
 726      */
 727     public abstract Image createImage(URL url);
 728 
 729     /**
 730      * Prepares an image for rendering.
 731      * <p>
 732      * If the values of the width and height arguments are both
 733      * {@code -1}, this method prepares the image for rendering


< prev index next >