Java Doc for ImageIcon.java in  » 6.0-JDK-Core » swing » javax » swing » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » swing » javax.swing 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   javax.swing.ImageIcon

ImageIcon
public class ImageIcon implements Icon,Serializable,Accessible(Code)
An implementation of the Icon interface that paints Icons from Images. Images that are created from a URL, filename or byte array are preloaded using MediaTracker to monitor the loaded state of the image.

For further information and examples of using image icons, see How to Use Icons in The Java Tutorial.

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder .
version:
   1.60 05/05/07
author:
   Jeff Dinkins
author:
   Lynn Monsanto


Inner Class :protected class AccessibleImageIcon extends AccessibleContext implements AccessibleIcon,Serializable

Field Summary
final protected static  Componentcomponent
    
 Stringdescription
    
 intheight
    
transient  Imageimage
    
 ImageObserverimageObserver
    
transient  intloadStatus
    
final protected static  MediaTrackertracker
    
 intwidth
    

Constructor Summary
public  ImageIcon(String filename, String description)
     Creates an ImageIcon from the specified file.
public  ImageIcon(String filename)
     Creates an ImageIcon from the specified file.
public  ImageIcon(URL location, String description)
     Creates an ImageIcon from the specified URL.
public  ImageIcon(URL location)
     Creates an ImageIcon from the specified URL.
public  ImageIcon(Image image, String description)
     Creates an ImageIcon from the image.
public  ImageIcon(Image image)
     Creates an ImageIcon from an image object.
public  ImageIcon(byte[] imageData, String description)
     Creates an ImageIcon from an array of bytes which were read from an image file containing a supported image format, such as GIF, JPEG, or (as of 1.3) PNG.
public  ImageIcon(byte[] imageData)
     Creates an ImageIcon from an array of bytes which were read from an image file containing a supported image format, such as GIF, JPEG, or (as of 1.3) PNG.
public  ImageIcon()
     Creates an uninitialized image icon.

Method Summary
public  AccessibleContextgetAccessibleContext()
     Gets the AccessibleContext associated with this ImageIcon.
public  StringgetDescription()
     Gets the description of the image.
public  intgetIconHeight()
     Gets the height of the icon.
public  intgetIconWidth()
     Gets the width of the icon.
public  ImagegetImage()
     Returns this icon's Image.
public  intgetImageLoadStatus()
     Returns the status of the image loading operation.
public  ImageObservergetImageObserver()
     Returns the image observer for the image.
protected  voidloadImage(Image image)
     Loads the image, returning only when the image is loaded.
public synchronized  voidpaintIcon(Component c, Graphics g, int x, int y)
     Paints the icon.
public  voidsetDescription(String description)
     Sets the description of the image.
public  voidsetImage(Image image)
     Sets the image displayed by this icon.
public  voidsetImageObserver(ImageObserver observer)
     Sets the image observer for the image.
public  StringtoString()
     Returns a string representation of this image.

Field Detail
component
final protected static Component component(Code)



description
String description(Code)



height
int height(Code)



image
transient Image image(Code)



imageObserver
ImageObserver imageObserver(Code)



loadStatus
transient int loadStatus(Code)



tracker
final protected static MediaTracker tracker(Code)



width
int width(Code)




Constructor Detail
ImageIcon
public ImageIcon(String filename, String description)(Code)
Creates an ImageIcon from the specified file. The image will be preloaded by using MediaTracker to monitor the loading state of the image.
Parameters:
  filename - the name of the file containing the image
Parameters:
  description - a brief textual description of the image
See Also:   ImageIcon.ImageIcon(String)



ImageIcon
public ImageIcon(String filename)(Code)
Creates an ImageIcon from the specified file. The image will be preloaded by using MediaTracker to monitor the loading state of the image. The specified String can be a file name or a file path. When specifying a path, use the Internet-standard forward-slash ("/") as a separator. (The string is converted to an URL, so the forward-slash works on all systems.) For example, specify:
 new ImageIcon("images/myImage.gif") 
The description is initialized to the filename string.
Parameters:
  filename - a String specifying a filename or path
See Also:   ImageIcon.getDescription



ImageIcon
public ImageIcon(URL location, String description)(Code)
Creates an ImageIcon from the specified URL. The image will be preloaded by using MediaTracker to monitor the loaded state of the image.
Parameters:
  location - the URL for the image
Parameters:
  description - a brief textual description of the image
See Also:   ImageIcon.ImageIcon(String)



ImageIcon
public ImageIcon(URL location)(Code)
Creates an ImageIcon from the specified URL. The image will be preloaded by using MediaTracker to monitor the loaded state of the image. The icon's description is initialized to be a string representation of the URL.
Parameters:
  location - the URL for the image
See Also:   ImageIcon.getDescription



ImageIcon
public ImageIcon(Image image, String description)(Code)
Creates an ImageIcon from the image.
Parameters:
  image - the image
Parameters:
  description - a brief textual description of the image



ImageIcon
public ImageIcon(Image image)(Code)
Creates an ImageIcon from an image object. If the image has a "comment" property that is a string, then the string is used as the description of this icon.
Parameters:
  image - the image
See Also:   ImageIcon.getDescription
See Also:   java.awt.Image.getProperty



ImageIcon
public ImageIcon(byte[] imageData, String description)(Code)
Creates an ImageIcon from an array of bytes which were read from an image file containing a supported image format, such as GIF, JPEG, or (as of 1.3) PNG. Normally this array is created by reading an image using Class.getResourceAsStream(), but the byte array may also be statically stored in a class.
Parameters:
  imageData - an array of pixels in an image format supportedby the AWT Toolkit, such as GIF, JPEG, or (as of 1.3) PNG
Parameters:
  description - a brief textual description of the image
See Also:   java.awt.Toolkit.createImage



ImageIcon
public ImageIcon(byte[] imageData)(Code)
Creates an ImageIcon from an array of bytes which were read from an image file containing a supported image format, such as GIF, JPEG, or (as of 1.3) PNG. Normally this array is created by reading an image using Class.getResourceAsStream(), but the byte array may also be statically stored in a class. If the resulting image has a "comment" property that is a string, then the string is used as the description of this icon.
Parameters:
  imageData - an array of pixels in an image format supported bythe AWT Toolkit, such as GIF, JPEG, or (as of 1.3) PNG
See Also:   java.awt.Toolkit.createImage
See Also:   ImageIcon.getDescription
See Also:   java.awt.Image.getProperty



ImageIcon
public ImageIcon()(Code)
Creates an uninitialized image icon.




Method Detail
getAccessibleContext
public AccessibleContext getAccessibleContext()(Code)
Gets the AccessibleContext associated with this ImageIcon. For image icons, the AccessibleContext takes the form of an AccessibleImageIcon. A new AccessibleImageIcon instance is created if necessary. an AccessibleImageIcon that serves as the AccessibleContext of this ImageIcon
since:
   1.3



getDescription
public String getDescription()(Code)
Gets the description of the image. This is meant to be a brief textual description of the object. For example, it might be presented to a blind user to give an indication of the purpose of the image. The description may be null. a brief textual description of the image



getIconHeight
public int getIconHeight()(Code)
Gets the height of the icon. the height in pixels of this icon



getIconWidth
public int getIconWidth()(Code)
Gets the width of the icon. the width in pixels of this icon



getImage
public Image getImage()(Code)
Returns this icon's Image. the Image object for this ImageIcon



getImageLoadStatus
public int getImageLoadStatus()(Code)
Returns the status of the image loading operation. the loading status as defined by java.awt.MediaTracker
See Also:   java.awt.MediaTracker.ABORTED
See Also:   java.awt.MediaTracker.ERRORED
See Also:   java.awt.MediaTracker.COMPLETE



getImageObserver
public ImageObserver getImageObserver()(Code)
Returns the image observer for the image. the image observer, which may be null



loadImage
protected void loadImage(Image image)(Code)
Loads the image, returning only when the image is loaded.
Parameters:
  image - the image



paintIcon
public synchronized void paintIcon(Component c, Graphics g, int x, int y)(Code)
Paints the icon. The top-left corner of the icon is drawn at the point (x, y) in the coordinate space of the graphics context g. If this icon has no image observer, this method uses the c component as the observer.
Parameters:
  c - the component to be used as the observerif this icon has no image observer
Parameters:
  g - the graphics context
Parameters:
  x - the X coordinate of the icon's top-left corner
Parameters:
  y - the Y coordinate of the icon's top-left corner



setDescription
public void setDescription(String description)(Code)
Sets the description of the image. This is meant to be a brief textual description of the object. For example, it might be presented to a blind user to give an indication of the purpose of the image.
Parameters:
  description - a brief textual description of the image



setImage
public void setImage(Image image)(Code)
Sets the image displayed by this icon.
Parameters:
  image - the image



setImageObserver
public void setImageObserver(ImageObserver observer)(Code)
Sets the image observer for the image. Set this property if the ImageIcon contains an animated GIF, so the observer is notified to update its display. For example:
 icon = new ImageIcon(...)
 button.setIcon(icon);
 icon.setImageObserver(button);
 

Parameters:
  observer - the image observer



toString
public String toString()(Code)
Returns a string representation of this image. a string representing this image



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.