24.2 Loading, Displaying and Scaling Images
We begin our discussion with images. We’ll use several different images in this chapter. You can create your own images with software such as Adobe® Photoshop®, Corel® Paint Shop Pro®, Microsoft® Paint and G.I.M.P. (gimp.org
).
The applet of Fig. 24.1 uses Java Web Start and the JNLP FileOpenService
(package javax.jnlp
) to allow the user to select an image, then displays that image and allows the user to scale it. After the user selects an image, the applet gets the bytes from the file, then passes them to the ImageIcon
(package javax.swing
) constructor to create the image that will be displayed. Class ImageIcon
’s constructors can receive arguments of several different formats, including a byte
array ...
Get Java How to Program (early objects), 9/e 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.