java.lang.Objectjavax.swing.ImageIcon
public class ImageIcon
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 XMLEncoder.
| Nested Class Summary | |
|---|---|
protected class |
ImageIcon.AccessibleImageIcon
This class implements accessibility support for the ImageIcon class. |
| 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, JPEG, or (as of 1.3) PNG. |
|
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. |
|
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 | |
|---|---|
AccessibleContext |
getAccessibleContext()
Gets the AccessibleContext associated with this ImageIcon. |
String |
getDescription()
Gets the description of the image. |
int |
getIconHeight()
Gets the height of the icon. |
int |
getIconWidth()
Gets the width of the icon. |
Image |
getImage()
Returns this icon's Image. |
int |
getImageLoadStatus()
Returns the status of the image loading operation. |
ImageObserver |
getImageObserver()
Returns the image observer for the image. |
protected void |
loadImage(Image image)
Loads the image, returning only when the image is loaded. |
void |
paintIcon(Component c,
Graphics g,
int x,
int y)
Paints the icon. |
void |
setDescription(String description)
Sets the description of the image. |
void |
setImage(Image image)
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, 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)
filename string.
filename - a String specifying a filename or pathgetDescription()public ImageIcon(URL location, String description)
location - the URL for the imagedescription - a brief textual description of the imageImageIcon(String)public ImageIcon(URL location)
location - the URL for the imagegetDescription()public ImageIcon(Image image, String description)
image - the imagedescription - a brief textual description of the imagepublic ImageIcon(Image image)
image - the imagegetDescription(),
Image.getProperty(java.lang.String, java.awt.image.ImageObserver)
public 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 imageToolkit.createImage(java.lang.String)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) PNGToolkit.createImage(java.lang.String),
getDescription(),
Image.getProperty(java.lang.String, java.awt.image.ImageObserver)public ImageIcon()
| Method Detail |
|---|
protected void loadImage(Image image)
image - the imagepublic int getImageLoadStatus()
MediaTracker.ABORTED,
MediaTracker.ERRORED,
MediaTracker.COMPLETEpublic Image getImage()
Image.
Image object for this ImageIconpublic void setImage(Image image)
image - the imagepublic String getDescription()
public void setDescription(String description)
description - a brief textual description of the imagepublic 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 int getIconWidth()
getIconWidth in interface Iconpublic int getIconHeight()
getIconHeight in interface Iconpublic void setImageObserver(ImageObserver observer)
button.setIcon(icon); icon.setImageObserver(button);
observer - the image observerpublic ImageObserver getImageObserver()
public String toString()
public AccessibleContext getAccessibleContext()
getAccessibleContext in interface AccessibleCes informations proviennent du site de http://java.sun.com
Le contenu de cette page provient du site de Sun, et est généré depuis un cache sur l'infobrol après certains traitements automatisés. La présentation peut donc différer du document original, mais le contenu aussi. Vous pouvez utiliser ce bouton pour afficher la page originale du site de Sun :
Maintenir les pages en cache sur différents sites peut offrir plus de disponibilité.
Chaque page est indexée dans la base de donnée, ce qui permet de retrouver facilement les informations, au moyen des sommaires, du moteur de recherche interne, etc.
Des facilités sont mises en place pour que les membres de l'infobrol puissent effectuer des traductions en français des différents documents. Ceci devrait permettre aux débutants en programmation Java de consulter les API en français s'ils maîtrisent moins bien la langue de Shakespeare. Dans le cas où une traduction a été soumise, elle est disponible au moyen d'un lien en bas de page. Si la traduction a été validée, la page s'affiche par défaut en français, et un lien en bas de page permet d'atteindre la version en anglais.
Le code sur l'infobrol est automatiquement coloré selon la syntaxe, et les différents mots clés sont transformés en liens pour accéder rapidement aux informations.
Vous avez la possibilité de partager vos expériences en proposant vos propres extraits de code en utilisant le bouton "ajouter un commentaire" en bas de page. Si vous visitez simplement l'infobrol, vous avez déjà accès à cette fonction, mais si vous étes membre du brol, vous pouvez en plus utiliser des boutons supplémentaires de mise en forme, dont la coloration automatique de vos extraits de codes.
Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.
6 mots clés dont 0 définis manuellement (plus d'information...).
Avertissement
Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.
Recherche (afficher)
Utilisateur (masquer)
Navigation (masquer)
Apparence (afficher)
Stats (afficher)
Citation (masquer)