Chapter 3

Using Images and Sound

In This Chapter

arrow Displaying images in Swing components

arrow Drawing images directly on a panel

arrow Scaling images

arrow Using a file chooser to pick an image

arrow Adding annoying sound effects and music to your programs

So far in this book, all the Swing applications have been pretty boring. They've had plenty of labels, text fields, combo boxes, and the like, but no pictures!

This chapter remedies that situation. You find out how to incorporate graphic images (that is, pictures — not necessarily images of a graphic nature) into your Swing applications. Just to make things interesting, I show you how to throw in sound effects and music, too.

technicalstuff.eps Java's support for images and sound is designed assuming that you're going to use them in applets that run over a slow Internet connection. As a result, Java goes to great lengths to accommodate large files that can take a long time ...

Get Java All-in-One For Dummies, 4th 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.