Friday, 15 November 2013

Inserting Picture Using Java Program




AIM:
         To write a java program to insert the pictures.

ALGORITHM:
        Step1:Create a class pic that inherits  applet.
        Step2:Create image img, img1, and URL u.
        Step3:In init method, using getImage method get the image from the system and store it in
                    Img and img1.
        Step4:In  paint method, using  drawImage  method display the images.


PROGRAM CODE


Import java.applet.*;
Import java.awt.*;
import java.net.*;
/*<applet code="Pic" width=200 height=200></applet>*/
public class Pic extends Applet
{
 Image img;
 URL u;
public void init()
 {
  u=getCodeBase();
img=getImage(u,"CG.jpg");
  }
public void paint(Graphics g)
 {
g.drawImage(img,0,0,this);
 }
}



OUTPUT







See the Above Program and Post Your Comments Below


No comments:

Post a Comment