|
Day 21: Handling User Events with Swing
NOTES AND CORRECTIONS
SOURCE FILES
READER QUESTIONS
- Q: I know in Applet we can use getImage() and drawImage() to
use images. How can I add images to a standalone AWT application?
A: If you use Swing instead of the AWT, which I recommend, one way to
include an image in your application is to create an ImageIcon object
that contains the image. The book doesn't cover this class, though I was
able to get it into the expanded Professional
Reference Edition. Check out Sun's documentation for javax.swing.ImageIcon.
To start you off, you can create an ImageIcon with a constructor like
this:
- ImageIcon ike = new ImageIcon("eisenhower.gif");
LINKS
|