This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

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: 4989

This tutorial should help:

luck, db
There are no new questions, but there may be new answers.
Have you checked out Aspose?
subject: Unable to view image in applet
It's not a secret anymore!