Results 1 to 4 of 4
Thread: Displaying an Image!
- 02-15-2012, 11:16 AM #1
Member
- Join Date
- Feb 2012
- Posts
- 23
- Rep Power
- 0
Displaying an Image!
Hi,
Im very new to java . So please bear with me.
I have faced the following problem with the given code:
import java.applet.Applet;
import java.awt.*;
import java.awt.Image;
import java.net.URL;
public class PaintBanner extends Applet{
Image testImage;
public void init(){
testImage = getImage("http://www.webdeveloper.com/animations/bnifiles/alladdin.gif");
}
public void paint(Graphics g){
g.drawImage(testImage,100,100,this);
}
}
I tried compiling it with javac PaintBanner.java
It is giving the following error:
PaintBanner.java:9: cannot find symbol
symbol : method getImage(java.lang.String)
location: class PaintBanner
testImage = getImage("http://www.webdeveloper.com/animations/bnifiles/alladdin.gif");
^
1 error
and Ive created a corresponding html file:
<html>
<body>
<applet code="PaintBanner.class" width=100 height=100>
</applet>
</body>
</html>
and Im not getting it how to display the image.. Ive been trying with appletviewer PaintBanner.html..
Can anyone please help me?
- 02-15-2012, 11:40 AM #2
Re: Displaying an Image!
It doesn't get much clearer than that. What made you think there's a getImage(...) method that takes a single String argument?cannot find symbol
symbol : method getImage(java.lang.String)
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 02-15-2012, 11:57 AM #3
Member
- Join Date
- Feb 2012
- Posts
- 23
- Rep Power
- 0
Re: Displaying an Image!
Its given in the java book... There was another option:
getImage(getDocumentBase(),"alladin.gif");
Now , eventhough this doesnt give an error while compilation,, while running the applet viewer it is giving a blank page.
- 02-15-2012, 12:08 PM #4
Re: Displaying an Image!
Burn the book and get one that has some quality. Or use The Java™ Tutorials online. You can find what you immediately need in the section on How to Make Applets (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)
Also, learn to read the API: Java Platform SE 6 / Java Platform SE 7
By the way, I hope you didn't waste money on that crappy book -- it's online for free. I won't post a link because I don't intend to inadvertently promote it, but did you know it dates to 1997? That's older than some of the kids who are already learning Java today.Why do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
Image not displaying
By sandeep43 in forum New To JavaReplies: 20Last Post: 07-08-2011, 12:31 AM -
Displaying an image
By BariMutation in forum New To JavaReplies: 6Last Post: 11-12-2010, 01:23 AM -
Displaying an image
By Samari413 in forum New To JavaReplies: 10Last Post: 11-06-2010, 08:56 PM -
Displaying an image
By SWEngineer in forum AWT / SwingReplies: 11Last Post: 01-28-2010, 05:48 AM -
Displaying image in same jsp
By SreenivasGurramkonda in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 12-08-2008, 06:01 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks