wood burning stoves 2.0*
The moose likes Applets and the fly likes Unable to view image in applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Unable to view image in applet" Watch "Unable to view image in applet" New topic

Unable to view image in applet

Mona Bajaj

Joined: Jan 27, 2013
Posts: 2
Hi All,

Unable to view image in applet.
I have saved the image where the .class file is saved, but when running the program(Eclipse), only blank applet viewer screen is displayed.
Please let me know in which folder, the image should be saved.

Please refer the below code

package practice_2;

import java.applet.*;
import java.awt.*;

public class ImageDemo extends Applet {
private static final long serialVersionUID = 1L;

private Image img;

public void init() {
img = getImage(getDocumentBase(), getParameter("img"));

public void paint(Graphics g) {
g.drawImage(img, 10,0, this);

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
try it like this

Mona Bajaj

Joined: Jan 27, 2013
Posts: 2
tried that way then also facing the problem.

Same problem i am facing when m trying to add image to icon in basic swing program.

Please tell me the exact location where the image file should be saved .
Darryl Burke

Joined: May 03, 2008
Posts: 4523

This tutorial should help: http://docs.oracle.com/javase/tutorial/uiswing/components/icon.html#getresource

luck, db
There are no new questions, but there may be new answers.
I agree. Here's the link: http://aspose.com/file-tools
subject: Unable to view image in applet
Similar Threads
applet in jar does not work
Doubt in Images of AWT?
Can't see image
Need Help Loading couple images to a BufferedImage.