code: public void setImage(BufferedImage img) {
          this.img = img;
          Dimension dim;
          if (img != null) {
              dim = new Dimension(img.getWidth(), img.getHeight());
          } else {
              dim = new Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT);
          }
  
          setSize(dim);
          setPreferredSize(dim);
          repaint();
      }
docs: Sets the image to be displayed.
  
  @param img
  the image to be displayed