Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Paint an Image 
 

This section provides you to paint an image on the frame. Paint means draw an image and set its on the frame to the specified location according to its x coordinate and y coordinate.

 

Paint an Image

                         

This section provides you to paint an image on the frame. Paint means draw an image and set its on the frame to the specified location according to its x coordinate and y coordinate.

Description of program:

In this program you will see how to paint an image on the fame to specified location. For this you need images that have to be set on the frame. Here first of all draw a rectangle and set the two images on to rectangle. Paint the rectangle in the yellow color. All drawing process is done using the paint() method. 

Here is the code of program:

import java.awt.*;
import java.awt.event.*;

public class PaintIcon extends Frame{
  Image image;
  public static void main(String[] args) {
    new PaintIcon();
  }
  public PaintIcon(){
    setTitle("Paint an Icon example!");
    setSize(200,200);
    setVisible(true);
    addWindowListener(new WindowAdapter(){
      public void windowClosing(WindowEvent we){
        System.exit(0);
      }
    });
  }
  public void paint(Graphics g){
    Toolkit tool = Toolkit.getDefaultToolkit();
    image = tool.getImage("warning.gif");
    g.drawRect(20,50,100,100);
    g.drawString("Draw Images:",20,40);
    g.setColor(Color.yellow);
    g.fillRect(20,50,100,100);
    g.drawImage(image,30,85,this);
    image = tool.getImage("Tom.gif");
    g.drawImage(image,80,85,this);
    
  }
}

Download this example.

Output of program:

                         

» View all related tutorials
Related Tags: c class make method sed boolean value ole set oo frame if boo to ram bool argument e il not

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.