ImageIcon public ImageIcon(String filename)根据指定的文件创建一个 ImageIcon。 实现接口Icon new ImageIcon("images/myImage.gif") paintIcon public void paintIcon(Component c, Graphics g, int x, int y)绘制图标。图标的左上角在图形上下文 g 的坐标空间中的点 (x, y) 处绘制。如果此图标没有图像观察者,则此方法使用 c 组件作为观察者。 参考一下............
我现在建了一个应用程序,在我的 public class GuiPanel extends JPanel{ JLabel jLabel1 = new JLabel(); Icon icon = null;public void repaint() { icon = new IconJAI(process()); jLabel1.setIcon(icon); Dimension iconSize = new Dimension(icon.getIconWidth(), icon.getIconHeight()); jLabel1.setPreferredSize(iconSize); jLabel1.revalidate(); } }
getImage
public abstract Image getImage(String filename)
返回一幅图像,该图像从指定文件中获取像素数据,图像格式可以是 GIF、JPEG 或 PNG
public ImageIcon(String filename)根据指定的文件创建一个 ImageIcon。
实现接口Icon
new ImageIcon("images/myImage.gif")
paintIcon
public void paintIcon(Component c,
Graphics g,
int x,
int y)绘制图标。图标的左上角在图形上下文 g 的坐标空间中的点 (x, y) 处绘制。如果此图标没有图像观察者,则此方法使用 c 组件作为观察者。
参考一下............
public class GuiPanel extends JPanel{
JLabel jLabel1 = new JLabel();
Icon icon = null;public void repaint() {
icon = new IconJAI(process());
jLabel1.setIcon(icon);
Dimension iconSize = new Dimension(icon.getIconWidth(),
icon.getIconHeight());
jLabel1.setPreferredSize(iconSize);
jLabel1.revalidate();
}
}