|
-
Image won't display in Applet
Hi people,
I'm trying to display an image (gif image) in an applet,
however, it does not show up when the applet is run.
Here is my code:
---------------------------------------------------------
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Image;
// An applet that loads an image and
// displays it.
public class DrawImage extends Applet
{
Image image; //an 'Image' object
//initialise applet
public void init()
{
//Load Image into object 'image'
//URL url , String file
image = getImage(getCodeBase(), "gifpic.gif");
}
//applet's paint function
public void paint(Graphics g)
{
if(image != null)
{ //if image is found then drawImage()
g.drawImage(image, 0, 0, this);
}
else
{ //if image is not found, then display message
System.out.println("image not found");
}
}
}
-----------------------------------------------------------------------
Similar Threads
-
Replies: 3
Last Post: 06-08-2005, 04:22 AM
-
By stephenbs in forum Java
Replies: 0
Last Post: 04-12-2005, 02:27 PM
-
Replies: 2
Last Post: 04-05-2005, 10:53 PM
-
Replies: 3
Last Post: 08-30-2001, 11:45 AM
-
Replies: 1
Last Post: 08-01-2000, 01:51 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks