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


SHARE

Milan Tomic

Hi. I’m Designer of Blog Magic. I’m CEO/Founder of ThemeXpose. I’m Creative Art Director, Web Designer, UI/UX Designer, Interaction Designer, Industrial Designer, Web Developer, Business Enthusiast, StartUp Enthusiast, Speaker, Writer and Photographer. Inspired to make things looks better.

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment