Click here to Skip to main content
15,901,951 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Here is the LoadImage class to load image from file

the applet window appears but the image doesnt loads, also what type of image are loadable jpegs, gifs or png's

What I have tried:

package DrawImage;

   import java.net.*;
   import java.awt.*;

   public class LoadImage extends java.applet.Applet
   {
       Image uc  ;
       URL base;
       MediaTracker mt;

       public void init()
       {
           mt = new MediaTracker(this);
           try{
                   base = getDocumentBase();
                   }catch(Exception e){}

           uc = getImage(base, "aerodynamics.gif");
           mt.addImage(uc,1);

           try{
           mt.waitForAll();
           }catch(InterruptedException e){}
   }

       public void paint(Graphics g)
   {
           g.drawImage(uc, 45  , 45, Color.yellow, this);
       }
  }
Posted
Updated 20-Feb-17 0:39am
v2

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900