package com.vistech.rmi;
import java.io.*;
import java.rmi.*;
import java.rmi.registry.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.tree.*;
import java.awt.*;
import java.awt.image.*;

public class ImagePanel extends JPanel{
   protected Image image;
   protected int viewerWid = 400;
   protected int viewerHt = 600;

   public void setImage(Image img){ image = img;}

   public void paintComponent(Graphics g){
      Rectangle rect = this.getBounds();
      g.setColor(Color.black);
      if((viewerWid != rect.width) || (viewerHt != rect.height)){
          viewerWid = rect.width; viewerHt = rect.height ;
          repaint(); return;
      }
      g.setColor(Color.black);
      g.fillRect(0,0,rect.width, rect.height);
      if(image != null){
         g.drawImage(image,0,0,rect.width,rect.height, this);
      }
   }
}