File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Unable to view image in applet" Watch "Unable to view image in applet" New topic
Author

Unable to view image in applet

Mona Bajaj
Greenhorn

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
Greenhorn

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
Bartender

Joined: May 03, 2008
Posts: 4658
    
    5

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