public class ImageIcon extends Object implements Icon, Serializable, Accessible
为进一步利用图像图标信息和例子,看到在java教程How to Use Icons。
警告:序列化该类的对象与以后的Swing版本不兼容。当前的序列化支持适用于短期贮藏或RMI运行相同Swing版本的应用程序之间。为1.4,为所有JavaBeans™长期存储的支持已被添加到java.beans
包。请看XMLEncoder
。
Modifier and Type | Class and Description |
---|---|
protected class |
ImageIcon.AccessibleImageIcon
这个类实现了对
ImageIcon 类可访问性支持。
|
Modifier and Type | Field and Description |
---|---|
protected static Component |
component
过时的。
自1.8
|
protected static MediaTracker |
tracker
过时的。
自1.8
|
Constructor and Description |
---|
ImageIcon()
创建一个未初始化图像图标。
|
ImageIcon(byte[] imageData)
创建从字节是从包含支持的图像格式的图像文件的读取数组的一个按钮,如GIF,JPEG,PNG或(如1.3)。
|
ImageIcon(byte[] imageData, String description)
创建从字节是从包含支持的图像格式的图像文件的读取数组的一个按钮,如GIF,JPEG,PNG或(如1.3)。
|
ImageIcon(Image image)
创建从一个图像对象的按钮。
|
ImageIcon(Image image, String description)
创建一个按钮的图像。
|
ImageIcon(String filename)
创建一个按钮从指定的文件。
|
ImageIcon(String filename, String description)
创建一个按钮从指定的文件。
|
ImageIcon(URL location)
创建一个按钮从指定的URL。
|
ImageIcon(URL location, String description)
创建一个按钮从指定的URL。
|
Modifier and Type | Method and Description |
---|---|
AccessibleContext |
getAccessibleContext()
获取与此相关的accessiblecontext按钮。
|
String |
getDescription()
获取图像的描述。
|
int |
getIconHeight()
获取图标的高度。
|
int |
getIconWidth()
获取图标的宽度。
|
Image |
getImage()
返回此图标的
Image 。
|
int |
getImageLoadStatus()
返回图像加载操作的状态。
|
ImageObserver |
getImageObserver()
返回图像的图像观察者。
|
protected void |
loadImage(Image image)
加载图像,仅在加载图像时返回。
|
void |
paintIcon(Component c, Graphics g, int x, int y)
油漆图标。
|
void |
setDescription(String description)
设置图像的描述。
|
void |
setImage(Image image)
设置由该图标显示的图像。
|
void |
setImageObserver(ImageObserver observer)
设置图像的图像观察者。
|
String |
toString()
返回此图像的字符串表示形式。
|
@Deprecated protected static final Component component
@Deprecated protected static final MediaTracker tracker
public ImageIcon(String filename, String description)
filename
-包含图像的文件名
description
-图像的一个简短的文字描述
ImageIcon(String)
@ConstructorProperties(value="description") public ImageIcon(String filename)
新的按钮(“图像/ myimage。gif”)描述初始化为
filename
字符串。
filename
-指定一个文件名或路径
getDescription()
public ImageIcon(URL location, String description)
location
为图像的URL
description
-图像的一个简短的文字描述
ImageIcon(String)
public ImageIcon(URL location)
location
为图像的URL
getDescription()
public ImageIcon(Image image, String description)
image
-图像
description
-图像的一个简短的文字描述
public ImageIcon(Image image)
image
-图像
getDescription()
,
Image.getProperty(java.lang.String, java.awt.image.ImageObserver)
public ImageIcon(byte[] imageData, String description)
imageData
-在一个由AWT工具包支持的图像格式的像素,如GIF,JPEG,PNG或(如1.3)
description
-图像的一个简短的文字描述
Toolkit.createImage(java.lang.String)
public ImageIcon(byte[] imageData)
imageData
-在一个由AWT工具包支持的图像格式的像素,如GIF,JPEG,PNG或(如1.3)
Toolkit.createImage(java.lang.String)
,
getDescription()
,
Image.getProperty(java.lang.String, java.awt.image.ImageObserver)
public ImageIcon()
protected void loadImage(Image image)
image
-图像
public int getImageLoadStatus()
MediaTracker.ABORTED
,
MediaTracker.ERRORED
,
MediaTracker.COMPLETE
public Image getImage()
Image
。
ImageIcon
的
Image
对象
public void setImage(Image image)
image
-图像
public String getDescription()
public void setDescription(String description)
description
-图像的一个简短的文字描述
public void paintIcon(Component c, Graphics g, int x, int y)
x
,
y
)在图形上下文
g
坐标空间。如果此图标没有图像的观察者,这种方法使用
c
成分为观察者。
public int getIconWidth()
getIconWidth
接口
Icon
public int getIconHeight()
getIconHeight
接口
Icon
public void setImageObserver(ImageObserver observer)
图标=新的按钮(…)按钮操作SetIcon(图标);setimageobserver图标(按钮);
observer
-图像观察
public ImageObserver getImageObserver()
public AccessibleContext getAccessibleContext()
getAccessibleContext
接口
Accessible
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.