|
JavaTM 2 Platform Standard Edition |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.swing.ImageIcon
An implementation of the Icon interface that paints Icons from Images. Images that are created from a URL or filename are preloaded using MediaTracker to monitor the loaded state of the image.
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. A future release of Swing will provide support for long term persistence.
Field Summary | |
protected static Component |
component
|
protected static MediaTracker |
tracker
|
Constructor Summary | |
ImageIcon()
Creates an uninitialized image icon. |
|
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 or JPEG. |
|
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 or JPEG. |
|
ImageIcon(Image image)
Creates an ImageIcon from an image object. |
|
ImageIcon(Image image,
String description)
Creates an ImageIcon from the image. |
|
ImageIcon(String filename)
Creates an ImageIcon from the specified file. |
|
ImageIcon(String filename,
String description)
Creates an ImageIcon from the specified file. |
|
ImageIcon(URL location)
Creates an ImageIcon from the specified URL. |
|
ImageIcon(URL location,
String description)
Creates an ImageIcon from the specified URL. |
Method Summary | |
String |
getDescription()
Get the description of the image. |
int |
getIconHeight()
Get the height of the Icon |
int |
getIconWidth()
Get the width of the Icon |
Image |
getImage()
Returns the Icon's Image |
int |
getImageLoadStatus()
Returns the status of the image loading operation. |
ImageObserver |
getImageObserver()
Return the umage observer for the image |
protected void |
loadImage(Image image)
Wait for the image to load |
void |
paintIcon(Component c,
Graphics g,
int x,
int y)
Paints the Icon |
void |
setDescription(String description)
Set the description of the image. |
void |
setImage(Image image)
Set the image displayed by this icon. |
void |
setImageObserver(ImageObserver observer)
Set the image observer for the image. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected static final Component component
protected static final MediaTracker tracker
Constructor Detail |
public ImageIcon(String filename, String description)
filename
- the name of the file containing the imagedescription
- a brief textual description of the imageImageIcon(String)
public ImageIcon(String filename)
new ImageIcon("images/myImage.gif")(The string is converted to an URL, so the forward-slash works on all systems.)
filename
- a String specifying a filename or pathpublic ImageIcon(URL location, String description)
URL
- the URL for the imagedescription
- a brief textual description of the imageImageIcon(String)
public ImageIcon(URL location)
public ImageIcon(Image image, String description)
image
- the imagedescription
- a brief textual description of the imagepublic ImageIcon(Image image)
public ImageIcon(byte[] imageData, String description)
imageData
- an array of pixels in an image format supported
by the AWT Toolkit, such as GIF or JPEG.description
- a brief textual description of the imageToolkit.createImage(java.lang.String)
public ImageIcon(byte[] imageData)
an
- array of pixels in an image format supported by
the AWT Toolkit, such as GIF or JPEG.Toolkit.createImage(java.lang.String)
public ImageIcon()
Method Detail |
protected void loadImage(Image image)
public int getImageLoadStatus()
MediaTracker.ABORTED
,
MediaTracker.ERRORED
,
MediaTracker.COMPLETE
public Image getImage()
public void setImage(Image image)
public String getDescription()
public void setDescription(String description)
public void paintIcon(Component c, Graphics g, int x, int y)
public int getIconWidth()
public int getIconHeight()
public void setImageObserver(ImageObserver observer)
icon = new ImageIcon(...) button.setIcon(icon); icon.setImageObserver(button);
public ImageObserver getImageObserver()
|
JavaTM 2 Platform Standard Edition |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |