try{
   java.awt.image.BufferedImage bi = 
         javax.imageio.ImageIO.read(InputStream your_stream);   javax.swing.ImageIcon myIcon = new javax.swing.ImageIcon(bi);
}catch(java.io.IOException){}

解决方案 »

  1.   

    ImageIO 是jb8才有的吧!
    如何平铺、拉伸、居中,有什么好一点方法吗?
      

  2.   

    你的困惑我也一直在想,不过昨天我突然间看到这个类(在javadoc里面)
    java.awt.Toolkit
    他有如下的方法:
    public Image createImage(byte[] imagedata)
    这个类是一个抽象的类,但是他又一个单子的实例化方法
    public static Toolkit getDefaultToolkit()
    程序片如下:Toolkit tool=Toolkit.getDefaultToolkit();
    byte[] b=//从网络下得到的byte流
    Image image=tool.createImage(b);祝你好运!
      

  3.   

    针对Image的操作方法:
    ImageIcon myIcon=new ImageIcon();
    try{
       java.awt.image.BufferedImage bi = 
             javax.imageio.ImageIO.read(InputStream your_stream);   myIcon = new javax.swing.ImageIcon(bi);
    }catch(java.io.IOException){}
       ImageIcon newIcon = new ImageIcon(tmpIcon.getImage().
                                     getScaledInstance(90, -1,
                                           Image.SCALE_DEFAULT));关于getScalInstance()函数,参见帮助文档,下面的简单介绍:
    public Image getScaledInstance(int width,int height,int hints)Parameters:
         width - the width to which to scale the image.
         height - the height to which to scale the image.
         hints - flags to indicate the type of algorithm to use for image resampling. 
    Returns:
         a scaled version of the image.
      

  4.   

    有一处写错了,如下:
       ImageIcon newIcon = new ImageIcon(myIcon.getImage().
                                     getScaledInstance(90, -1,
                                           Image.SCALE_DEFAULT));