private void initComponents() {
    setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);

    messagePane.setBackground(contentPane.getBackground());
    messagePane.setEditorKit(new HTMLEditorKit());
    messagePane.setForeground(contentPane.getForeground());

    setSize(450, 360);

    // center the window
    int x = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() - getWidth()) / 2;
    int y = (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() - getHeight()) / 2;
    setLocation(x, y);

    okButton.addActionListener(this);
  }
  /**
   * Added this guy to make sure an image is loaded - ie no broken images. So far its used only for
   * images loaded off the disk (non-URL). It seems to work marvelously. By the way, it does the
   * same thing as MediaTracker, but you dont need to know the component its being rendered on. Rob
   */
  private void waitForImage() throws InterruptedException {
    int w = fImage.getWidth(this);
    int h = fImage.getHeight(this);

    while (true) {
      int flags = Toolkit.getDefaultToolkit().checkImage(fImage, w, h, this);

      if (((flags & ERROR) != 0) || ((flags & ABORT) != 0)) throw new InterruptedException();
      else if ((flags & (ALLBITS | FRAMEBITS)) != 0) return;
      Thread.sleep(10);
      // System.out.println("rise and shine...");
    }
  }
  private void initialize(Element elem) {
    synchronized (this) {
      loading = true;
      fWidth = fHeight = 0;
    }
    int width = 0;
    int height = 0;
    boolean customWidth = false;
    boolean customHeight = false;
    try {
      fElement = elem;

      // Request image from document's cache:
      AttributeSet attr = elem.getAttributes();
      if (isURL()) {
        URL src = getSourceURL();
        if (src != null) {
          Dictionary cache = (Dictionary) getDocument().getProperty(IMAGE_CACHE_PROPERTY);
          if (cache != null) fImage = (Image) cache.get(src);
          else fImage = Toolkit.getDefaultToolkit().getImage(src);
        }
      } else {

        /** ****** Code to load from relative path ************ */
        String src = (String) fElement.getAttributes().getAttribute(HTML.Attribute.SRC);
        System.out.println("before src: " + src);
        src = processSrcPath(src);
        System.out.println("after src: " + src);
        fImage = Toolkit.getDefaultToolkit().createImage(src);
        try {
          waitForImage();
        } catch (InterruptedException e) {
          fImage = null;
        }
        /** *************************************************** */
      }

      // Get height/width from params or image or defaults:
      height = getIntAttr(HTML.Attribute.HEIGHT, -1);
      customHeight = (height > 0);
      if (!customHeight && fImage != null) height = fImage.getHeight(this);
      if (height <= 0) height = DEFAULT_HEIGHT;

      width = getIntAttr(HTML.Attribute.WIDTH, -1);
      customWidth = (width > 0);
      if (!customWidth && fImage != null) width = fImage.getWidth(this);
      if (width <= 0) width = DEFAULT_WIDTH;

      // Make sure the image starts loading:
      if (fImage != null)
        if (customWidth && customHeight)
          Toolkit.getDefaultToolkit().prepareImage(fImage, height, width, this);
        else Toolkit.getDefaultToolkit().prepareImage(fImage, -1, -1, this);

      /**
       * ****************************************************** // Rob took this out. Changed scope
       * of src. if( DEBUG ) { if( fImage != null ) System.out.println("ImageInfo: new on "+src+ "
       * ("+fWidth+"x"+fHeight+")"); else System.out.println("ImageInfo: couldn't get image at "+
       * src); if(isLink()) System.out.println(" It's a link! Border = "+ getBorder());
       * //((AbstractDocument.AbstractElement)elem).dump(System.out,4); }
       * ******************************************************
       */
    } finally {
      synchronized (this) {
        loading = false;
        if (customWidth || fWidth == 0) {
          fWidth = width;
        }
        if (customHeight || fHeight == 0) {
          fHeight = height;
        }
      }
    }
  }