Simple image handling

In the simplest form the image can be loaded in memory and displayed on screen using only two methods.

o = getImage(getDocumentBase(),"example.gif")

This loads the image (in the same folder as the class) and returns it to the image object o.

g.drawImage(o,0,0,this);

This draws the image o in the current graphics screen g.



import java.applet.*;
import java.awt.*;
import java.awt.image.*;
public class zzz extends Applet
     {       Image o;
             public void init()
             {       o=getImage(getDocumentBase(),"example.gif");
             }
             public void paint(Graphics g)
             {       g.drawImage(o,0,0,this);
             }
     }

The result shows as follows