Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2012
    Posts
    23
    Rep Power
    0

    Default 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?

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,304
    Rep Power
    20

    Default Re: Displaying an Image!

    cannot find symbol
    symbol : method getImage(java.lang.String)
    It doesn't get much clearer than that. What made you think there's a getImage(...) method that takes a single String argument?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Join Date
    Feb 2012
    Posts
    23
    Rep Power
    0

    Default 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.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,304
    Rep Power
    20

    Default Re: Displaying an Image!

    Quote Originally Posted by javabeginner29 View Post
    Its given in the java book.
    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.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Image not displaying
    By sandeep43 in forum New To Java
    Replies: 20
    Last Post: 07-08-2011, 12:31 AM
  2. Displaying an image
    By BariMutation in forum New To Java
    Replies: 6
    Last Post: 11-12-2010, 01:23 AM
  3. Displaying an image
    By Samari413 in forum New To Java
    Replies: 10
    Last Post: 11-06-2010, 08:56 PM
  4. Displaying an image
    By SWEngineer in forum AWT / Swing
    Replies: 11
    Last Post: 01-28-2010, 05:48 AM
  5. Displaying image in same jsp
    By SreenivasGurramkonda in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 12-08-2008, 06:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •