11 Replies Latest reply: Feb 23, 2009 9:35 AM by 807588 RSS

    Getting error while using getImage(URL, filename) and imageUpdate()

    807588
      Hello Everyone,

      I am trying to create an image and upload it in an applet. I have kept the image file in the same directory as of the HTML and java-applet file. I have used the getImage(URL, filename) abstract method to do so. The image is not getting uploaded .... PLEASE HELP .... Please find the code attached below.
      import java.awt.*;
      import java.awt.image.*;
      import java.applet.*;
      /*<applet code="ImageCreation_applet" width=1200 height=400>
      </applet>*/
      public class ImageCreation_applet extends Applet implements ImageObserver
           {
           //     Image image1;
                Image image2;
                String s="";
                String image_name="img2";
                public void init()
                     {
                          setBackground(Color.yellow);
           //               Canvas c=new Canvas();
           //               image1=c.createImage(40, 40);
      
                          image2=this.getImage(this.getDocumentBase());
                     }
                public void paint(Graphics g)
                     {
                     //     g.drawImage(image1, 50, 50, this);
                          g.drawImage(image2, 0, 0, this);
                          g.drawString(s, 300, 300);
                     }
                public boolean imageUpdate(Image img, int flags, int x, int y, int w, int h)
                     {
                          if((flags & SOMEBITS) != 0)
                               {     
                                    repaint(x, y, w, h);
                               }
                          else if((flags & ABORT) != 0)
                               {
                                    s="ERROR";
                                    repaint();
                               }
                          return (flags & (ALLBITS|ABORT)) == 0;
                     }
           }
      I am continuously getting the ERROR String.... PLEASE HELP