Summary

Section 21.2 Loading, Displaying and Scaling Images

  • Applet method getImage loads an Image.

  • Applet method getDocumentBase returns the location of the applet’s HTML file on the Internet as an object of class URL.

  • Java supports several image formats, including Graphics Interchange Format (GIF), Joint Photographic Experts Group (JPEG) and Portable Network Graphics (PNG). The file names for these types end with .gif, .jpg (or .jpeg) and .png, respectively.

  • Class ImageIcon provides constructors that allow an ImageIcon object to be initialized with an image from the local computer or stored on a web server on the Internet.

  • Graphics method drawImage accepts four arguments—a reference to the Image object in which the image is stored, the x- and ...

Get Java™ How to Program, Seventh Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.