Ecco quello che ho fatto, magari puo' tornare utile a qualcuno.
codice:
private class ImageComponent extends JPanel
{
public ImageComponent() {}
public ImageComponent (byte[] image)
{
ByteArrayInputStream bis = new ByteArrayInputStream (image);
try {
_image = ImageIO.read (bis);
}
catch (IOException ex){}
}
public void updateImage (byte[] image)
{
ByteArrayInputStream bis = new ByteArrayInputStream (image);
try {
_image = ImageIO.read (bis);
}
catch (IOException ex){}
repaint();
}
public void paint(Graphics g)
{
g.drawImage(_image, 0, 0, null);
}
public Dimension getPreferredSize()
{
if (_image == null) {
return new Dimension (320, 240);
} else {
return new Dimension (_image.getWidth (null), _image.getHeight (null));
}
}
BufferedImage _image;
}
In pratica ho creato una classe che estende un Jpanel (in realta' potevo anche estendere Component direttamente) che riceve un byte array tramite il metodo updateImage(), dopo di che lo legge come BufferedImage passando per un ByteArrayInputStream. Poi chiamo repaint() che quindi mi ridisegna il componente con la nuova immagine che gli ho passato.