aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/javax/swing/ImageIcon.java
diff options
context:
space:
mode:
authorTom Tromey <tromey@gcc.gnu.org>2005-09-23 21:31:04 +0000
committerTom Tromey <tromey@gcc.gnu.org>2005-09-23 21:31:04 +0000
commit1ea63ef8be1cc54dd0de9d82c684713a1dcf1e06 (patch)
tree3ca4b2e68dc14c3128b9c781d23f1d0b1f2bee49 /libjava/classpath/javax/swing/ImageIcon.java
parent9b044d19517541c95681d35a92dbc81e6e21d94f (diff)
downloadgcc-1ea63ef8be1cc54dd0de9d82c684713a1dcf1e06.zip
gcc-1ea63ef8be1cc54dd0de9d82c684713a1dcf1e06.tar.gz
gcc-1ea63ef8be1cc54dd0de9d82c684713a1dcf1e06.tar.bz2
Imported Classpath 0.18.
* sources.am, Makefile.in: Updated. * Makefile.am (nat_source_files): Removed natProxy.cc. * java/lang/reflect/natProxy.cc: Removed. * gnu/classpath/jdwp/VMFrame.java, gnu/classpath/jdwp/VMIdManager.java, gnu/classpath/jdwp/VMVirtualMachine.java, java/lang/reflect/VMProxy.java: New files. 2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com> * scripts/makemake.tcl (verbose): Add gnu/java/awt/peer/qt to BC list. 2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com> * gnu/java/net/DefaultContentHandlerFactory.java (getContent): Remove ClasspathToolkit references. 2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com> * gnu/awt/xlib/XCanvasPeer.java: Add new peer methods. * gnu/awt/xlib/XFramePeer.java: Likewise. * gnu/awt/xlib/XGraphicsConfiguration.java: Likewise. 2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com> * Makefile.am (libgcjawt_la_SOURCES): Remove jawt.c. Add classpath/native/jawt/jawt.c. * Makefile.in: Regenerate. * jawt.c: Remove file. * include/Makefile.am (tool_include__HEADERS): Remove jawt.h and jawt_md.h. Add ../classpath/include/jawt.h and ../classpath/include/jawt_md.h. * include/Makefile.in: Regenerate. * include/jawt.h: Regenerate. * include/jawt_md.h: Regenerate. From-SVN: r104586
Diffstat (limited to 'libjava/classpath/javax/swing/ImageIcon.java')
-rw-r--r--libjava/classpath/javax/swing/ImageIcon.java110
1 files changed, 101 insertions, 9 deletions
diff --git a/libjava/classpath/javax/swing/ImageIcon.java b/libjava/classpath/javax/swing/ImageIcon.java
index 36f23d2..b650cd8 100644
--- a/libjava/classpath/javax/swing/ImageIcon.java
+++ b/libjava/classpath/javax/swing/ImageIcon.java
@@ -53,6 +53,9 @@ import javax.accessibility.AccessibleIcon;
import javax.accessibility.AccessibleRole;
import javax.accessibility.AccessibleStateSet;
+/**
+ * An {@link Icon} implementation that is backed by an {@link Image}.
+ */
public class ImageIcon
implements Icon, Serializable, Accessible
{
@@ -219,92 +222,181 @@ public class ImageIcon
/** The AccessibleContext of this ImageIcon. */
private AccessibleContext accessibleContext;
+ /**
+ * Creates an ImageIcon without any properties set.
+ */
public ImageIcon()
{
}
-
- public ImageIcon(String file)
+
+ /**
+ * Constructs an ImageIcon given a filename. The icon's description
+ * is initially set to the filename itself. A filename of "" means
+ * create a blank icon.
+ *
+ * @param filename name of file to load or "" for a blank icon
+ */
+ public ImageIcon(String filename)
{
- this(file, file);
+ this(filename, filename);
}
- public ImageIcon(String file, String description)
+ /**
+ * Constructs an ImageIcon from the given filename, setting its
+ * description to the given description. A filename of "" means
+ * create a blank icon.
+ *
+ * @param filename name of file to load or "" for a blank icon
+ * @param description human-readable description of this icon
+ */
+ public ImageIcon(String filename, String description)
{
- this(Toolkit.getDefaultToolkit().getImage(file), description);
+ this(Toolkit.getDefaultToolkit().getImage(filename), description);
}
+ /**
+ * Creates an ImageIcon from the given byte array without any
+ * description set.
+ */
public ImageIcon(byte[] imageData)
{
this(imageData, null);
}
+ /**
+ * Creates an ImageIcon from the given byte array and sets the given
+ * description.
+ */
public ImageIcon(byte[] imageData, String description)
{
this(Toolkit.getDefaultToolkit().createImage(imageData), description);
}
+ /**
+ * Creates an ImageIcon from the given URL without any description
+ * set.
+ */
public ImageIcon(URL url)
{
this(url, null);
}
+ /**
+ * Creates an ImageIcon from the given URL and sets the given
+ * description.
+ */
public ImageIcon(URL url, String description)
{
this(Toolkit.getDefaultToolkit().getImage(url), description);
}
+ /**
+ * Creates an ImageIcon from the given Image without any description
+ * set.
+ */
public ImageIcon(Image image)
{
this(image, null);
}
+ /**
+ * Creates an ImageIcon from the given Image and sets the given
+ * description.
+ */
public ImageIcon(Image image, String description)
{
setImage(image);
setDescription(description);
}
-
+
+ /**
+ * Returns the ImageObserver that is used for all Image
+ * operations. Defaults to null when not explicitly set.
+ */
public ImageObserver getImageObserver()
{
return observer;
}
+ /**
+ * Sets the ImageObserver that will be used for all Image
+ * operations. Can be set to null (the default) when no observer is
+ * needed.
+ */
public void setImageObserver(ImageObserver newObserver)
{
observer = newObserver;
}
+ /**
+ * Returns the backing Image for this ImageIcon. Might be set to
+ * null in which case no image is shown.
+ */
public Image getImage()
{
return image;
}
+ /**
+ * Explicitly sets the backing Image for this ImageIcon. Will call
+ * loadImage() to make sure that the Image is completely loaded
+ * before returning.
+ */
public void setImage(Image image)
{
loadImage(image);
this.image = image;
}
+ /**
+ * Returns a human readable description for this ImageIcon or null
+ * when no description is set or available.
+ */
public String getDescription()
{
return description;
}
+ /**
+ * Sets a human readable description for this ImageIcon. Can be set
+ * to null when no description is available.
+ */
public void setDescription(String description)
{
this.description = description;
}
+ /**
+ * Returns the the height of the backing Image, or -1 if the backing
+ * Image is null. The getHeight() method of the Image will be called
+ * with the set observer of this ImageIcon.
+ */
public int getIconHeight()
{
+ if (image == null)
+ return -1;
+
return image.getHeight(observer);
}
+ /**
+ * Returns the the width of the backing Image, or -1 if the backing
+ * Image is null. The getWidth() method of the Image will be called
+ * with the set observer of this ImageIcon.
+ */
public int getIconWidth()
{
+ if (image == null)
+ return -1;
+
return image.getWidth(observer);
}
+ /**
+ * Calls <code>g.drawImage()</code> on the backing Image using the
+ * set observer of this ImageIcon. If the set observer is null, the
+ * given Component is used as observer.
+ */
public void paintIcon(Component c, Graphics g, int x, int y)
{
g.drawImage(image, x, y, observer != null ? observer : c);
@@ -338,9 +430,9 @@ public class ImageIcon
*
* @return the load status of the icon image
*
- * @see {@link MediaTracker.COMPLETE}
- * @see {@link MediaTracker.ABORTED}
- * @see {@link MediaTracker.ERRORED}
+ * @see MediaTracker#COMPLETE
+ * @see MediaTracker#ABORTED
+ * @see MediaTracker#ERRORED
*/
public int getImageLoadStatus()
{