| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
URL connectUrl = …;
ImageIcon connectIcon = new ImageIcon(connectUrl);
Based on 19 examples
ImageIcon cheerleader = new ImageIcon();
Based on 18 examples
public class ImageIcon extends Object implements Icon, Serializable, Accessible
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 {@link java.beans.XMLEncoder}.
Nested Class Summary | |
---|---|
protected class |
This class implements accessibility support for the ImageIcon class. |
Field Summary | |
---|---|
protected static Component |
component
|
protected static MediaTracker |
tracker
|
Constructor Summary | |
---|---|
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, JPEG, or (as of 1.3) PNG. |
|
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. |
|
Creates an ImageIcon from an image object. |
|
Creates an ImageIcon from the image. |
|
Creates an ImageIcon from the specified file. |
|
Creates an ImageIcon from the specified file. |
|
Creates an ImageIcon from the specified URL. |
|
Creates an ImageIcon from the specified URL. |
Method Summary | |
---|---|
AccessibleContext |
Gets the AccessibleContext associated with this ImageIcon. |
String |
Gets the description of the image. |
int |
Gets the height of the icon. |
int |
Gets the width of the icon. |
Image |
getImage() Returns this icon's Image .
|
int |
Returns the status of the image loading operation. |
ImageObserver |
Returns the image observer for the image. |
protected void |
Loads the image, returning only when the image is loaded. |
void |
Paints the icon. |
void |
setDescription(String description) Sets the description of the image. |
void |
Sets the image displayed by this icon. |
void |
setImageObserver(ImageObserver observer) Sets the image observer for the image. |
String |
toString() Returns a string representation of this 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()
public ImageIcon(byte[] imageData)
imageData
- an array of pixels in an image format supported by
the AWT Toolkit, such as GIF, JPEG, or (as of 1.3) PNGpublic ImageIcon(byte[] imageData, String description)
imageData
- an array of pixels in an image format supported
by the AWT Toolkit, such as GIF, JPEG, or (as of 1.3) PNGdescription
- a brief textual description of the imagepublic ImageIcon(Image image)
image
- the imagepublic ImageIcon(Image image, String description)
image
- the imagedescription
- a brief textual description of the imagepublic ImageIcon(String filename)
new ImageIcon("images/myImage.gif")The description is initialized to the
filename
string.
filename
- a String specifying a filename or pathpublic ImageIcon(String filename, String description)
filename
- the name of the file containing the imagedescription
- a brief textual description of the imagepublic ImageIcon(URL location)
location
- the URL for the imagepublic ImageIcon(URL location, String description)
location
- the URL for the imagedescription
- a brief textual description of the imageMethod Detail |
---|
public AccessibleContext getAccessibleContext()
public String getDescription()
public int getIconHeight()
public int getIconWidth()
public Image getImage()
Image
.
Image
object for this ImageIcon
public int getImageLoadStatus()
public ImageObserver getImageObserver()
protected void loadImage(Image image)
image
- the imagepublic synchronized void paintIcon(Component c, Graphics g, int x, int y)
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.
c
- the component to be used as the observer
if this icon has no image observerg
- the graphics contextx
- the X coordinate of the icon's top-left cornery
- the Y coordinate of the icon's top-left cornerpublic void setDescription(String description)
description
- a brief textual description of the imagepublic void setImage(Image image)
image
- the imagepublic void setImageObserver(ImageObserver observer)
icon = new ImageIcon(...) button.setIcon(icon); icon.setImageObserver(button);
observer
- the image observerpublic String toString()
toString
in class Object
| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |