Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML


 
  
 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 

 
Facing Programming Problem?
Ask Questions?, Browse Latest Questions, Question-Answer Guidelines
Java
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
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 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:

                         

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

Latest Searches:
Spyware and Adware Rem
code fro finding index
find out factors of nu
Photoshop Animation Sh
lookup
iterate nest
DAO connection pooling
draw Polyline
Telephony
struts2 file upload
java networking
excel from java
extract a piece of dat
joining queries in SQ
JPA
java �����??
struts <param name
myfaces tomahawk
convert string array t
notes on javax.sql.*
array list
diff. shape of linear
image file upload jsp
table model
c tutorial
Photoshop Photo Effect
loading bars images in
org.apache.poi.hssf.us
jdk1.4
<html:options>
jsp onchange
rs.relative
upsasting
project
Flash Simple Motion Tw
how to pass same varia
struts hibernate sprin
Scanner
compiler design
jdk1.3vsjdk1.4
seperator
Treemap using gwt tree
Easy Java Tutorials
java tutorial pdf
video tutorial
datalist
login
upload file
FORMAT YEARS
JSF datatree
is the jvm same for al
t:datalist
Dependency list box in
ensureCapacity of vect
Photoshop Text Reflect
Java GUI example
Component class in JSF
java applets
sum of digits
struts radio button
Determining If a Year
jsp standard tags
Jtable Jbutton
how to create a frame
jpanel
awt jdbc
asterisk
if statement in a JSP
? С??? С??? С???
table grid
sample code using stru
MurachÑ??Ð?Ñ?Ð?Ð??Ñ??Ð
jpa spring transaction
convert ASCII to char
struts formfile
rules
HWPF
Message Board JMB
Write a program that i
java inner class
Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

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 | 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.