This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Applets and the fly likes Images in applets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Images in applets" Watch "Images in applets" New topic

Images in applets

Ranu Kundu

Joined: Jul 05, 2010
Posts: 16
how to include images in applets???
I have tried this:

Image image; public void init() {
image = getImage(getDocumentBase(), "http://hostname/image.gif");
public void paint(Graphics g) {
g.drawImage(image, 0, 0, this);

But nothing is showing in applet.Why?
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 685
You seem to be passing two URLs to the getImage() method.
Read the API doc to see what the second arg should be.
I agree. Here's the link:
subject: Images in applets
Similar Threads
Using arrays to randomly generate images? (applet)
Applet permissions trouble
Need help with my game.
Drawing Image Doubles Memory Consumption
Applet, How to get the image displayed PLEASE HELP