Problem with refreshing bufferedimage object
From DB2 I get one BLOB, and I print this BLOB on JPanel (blob is BuffferedImage object). When the screen is minimised or another window comes on top of the main window, my image disappear. Why? I know, that I must override paintComponents() method, but I dont know how to do that. Any sugestions?
My printing code:
public void drawFoto(BufferedImage photo)
{
double skalaZdjW = 0;
double skalaZdjH = 0;
double skalaPodpisW = 0;
double skalaPodpisH = 0;
int skalaW = 0;
int skalaH = 0;
int skalaW1 = 0;
int skalaH1 = 0;
//scaling photo to panel dimensions
if (photo!=null)
{
skalaZdjW = (double)panFoto.getWidth()/
(double)photo.getWidth();
skalaZdjH = (double)panFoto.getHeight()/
(double)photo.getHeight();
if( skalaZdjW>skalaZdjH)
{
skalaH1 = (int)(photo.getHeight()*skalaZdjH);
skalaW1 = (int)(photo.getWidth()*skalaZdjH);
}
else
{
skalaH1 = (int)(photo.getHeight()*skalaZdjW)-5;
skalaW1 = (int)(photo.getWidth()*skalaZdjW)-5;
}
ImageObserver obs = null;
panFoto.getGraphics().clearRect(1,1,panFoto.getWidth(),panFoto.getHeight());
panFoto.getGraphics().drawImage(photo,5,20,skalaW1,skalaH1,obs);
}
}
best regards
C.

