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

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Image Demo 
 

This section simply display the image demo that means multiple images and its name are based on the frame to a particular location. For displaying images demo first of all you will need multiple images that have to be displayed on the frame. The following

 

Image Demo

                         

This section simply display the image demo that means multiple images and its name are based on the frame to a particular location. For displaying images demo first of all you will need multiple images that have to be displayed on the frame. The following program displays the images and its name on the frame by using the Toolkit, getImage(), drawString() and drawImage() methods.

Description of code:

drawImage(Image img, int x, int y, ImageObserver ob):
This method used to draw an image that have to used in it. It takes the following parameters:

        img: This is an image that have to be drown.
        x: This is the x coordinate.
        y: This is the y coordinate.
       ob: This is an object that have to be notified as more of the image is converted.

Here is the code of program:

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

public class ImageDemo extends Frame{
  Image image;
  public static void main(String[] args) {
      new ImageDemo();
  }
  public ImageDemo(){
    setTitle("Image Demo Example!");
    setSize(300,200);
    addWindowListener(new WindowAdapter(){
      public void windowClosing(WindowEvent we){
        System.exit(0);
      }
    });
    setVisible(true);
  }
  public void paint(Graphics g){
    Toolkit tool = Toolkit.getDefaultToolkit();
    image = tool.getImage("bt_home.gif");
    g.drawString("Image 1:",20,40);
    g.drawImage(image,20,45,this);
    image = tool.getImage("icon_mini_search.gif");
    g.drawString("Image 2:",20,80);
    g.drawImage(image,20,90,this);
    image = tool.getImage("apache_pb2_ani.gif");
    g.drawString("Image 3:",20,130);
    g.drawImage(image,20,150,this);
  }
}

Download this example.

Output of Program:

                         

» View all related tutorials
Related Tags: c gui com ide browser class stl ui applet io methods classes method sed apple nested override vi component panel

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 

Current Comments

2 comments so far (
post your own) View All Comments Latest 10 Comments:

How to comfile java's program? please help me. Thanks.

Posted by ronald on Wednesday, 09.24.08 @ 03:05am | #80645

can you help me please to display multiple images on one button, one image per click

Posted by seemo on Sunday, 02.3.08 @ 08:56am | #47061

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.