aboutsummaryrefslogtreecommitdiff
path: root/libjava/javax/swing/ImageIcon.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/javax/swing/ImageIcon.java')
-rw-r--r--libjava/javax/swing/ImageIcon.java123
1 files changed, 72 insertions, 51 deletions
diff --git a/libjava/javax/swing/ImageIcon.java b/libjava/javax/swing/ImageIcon.java
index da271a5..f94d58a 100644
--- a/libjava/javax/swing/ImageIcon.java
+++ b/libjava/javax/swing/ImageIcon.java
@@ -35,65 +35,86 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package javax.swing;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
+import java.io.Serializable;
+import java.net.URL;
+
-public class ImageIcon implements Icon
+public class ImageIcon
+ implements Icon, Serializable
{
- Image image;
- String file, descr;
- Component observer;
+ private static final long serialVersionUID = 532615968316031794L;
+ Image image;
+ String file;
+ String descr;
+ Component observer;
public ImageIcon(String s)
- {
- // if description is not specified, then file name becomes
- // desciption for this icon
-
- this(s, s);
- }
-
- public ImageIcon(String file,
- String descr)
- {
- this.file = file;
- this.descr = descr;
-
- image = Toolkit.getDefaultToolkit().getImage(file);
- if (image == null) {
- return;
- }
- //loadImage(image);
- }
-
- // not in SUN's spec !!!
- public void setParent(Component p)
- {
- observer = p;
- }
-
- public Image getImage()
- { return image; }
-
- public String getDescription()
- { return descr; }
- public void setDescription(String description)
- { this.descr = description; }
-
- public int getIconHeight()
- { return image.getHeight(observer); }
- public int getIconWidth()
- { return image.getWidth(observer); }
-
- public void paintIcon(Component c,
- Graphics g,
- int x,
- int y)
- {
- g.drawImage(image, x, y, observer);
- }
+ {
+ // if description is not specified, then file name becomes
+ // desciption for this icon
+ this(s, s);
+ }
+
+ public ImageIcon(Image image)
+ {
+ }
+
+ public ImageIcon(URL url)
+ {
+ image = Toolkit.getDefaultToolkit().getImage(url);
+ }
+
+ public ImageIcon(String file, String descr)
+ {
+ this.file = file;
+ this.descr = descr;
+
+ image = Toolkit.getDefaultToolkit().getImage(file);
+ if (image == null)
+ return;
+
+ //loadImage(image);
+ }
+
+ // not in SUN's spec !!!
+ public void setParent(Component p)
+ {
+ observer = p;
+ }
+
+ public Image getImage()
+ {
+ return image;
+ }
+
+ public String getDescription()
+ {
+ return descr;
+ }
+
+ public void setDescription(String description)
+ {
+ this.descr = description;
+ }
+
+ public int getIconHeight()
+ {
+ return image.getHeight(observer);
+ }
+
+ public int getIconWidth()
+ {
+ return image.getWidth(observer);
+ }
+
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ g.drawImage(image, x, y, observer);
+ }
}