/**
   * Sets the image to display in the frame.
   *
   * @param imageIcon the image to display in the frame
   */
  public void setImageIcon(ImageIcon imageIcon) {
    // Intercept the action to validate the user icon and not the default
    super.setImageIcon(imageIcon.getImage());
    this.isDefaultImage = false;

    this.currentImage = imageIcon.getImage();
  }
 public void squish(Graphics g, ImageIcon icon, int x, int y, double scale) {
   if (isVisible()) {
     g.drawImage(
         icon.getImage(),
         x,
         y,
         (int) (icon.getIconWidth() * scale),
         (int) (icon.getIconHeight() * scale),
         this);
   }
 }
 private static ImageIcon makeRolloverIcon(ImageIcon srcIcon) {
   RescaleOp op =
       new RescaleOp(new float[] {1.2f, 1.2f, 1.2f, 1f}, new float[] {0f, 0f, 0f, 0f}, null);
   BufferedImage img =
       new BufferedImage(
           srcIcon.getIconWidth(), srcIcon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
   Graphics g = img.getGraphics();
   // g.drawImage(srcIcon.getImage(), 0, 0, null);
   srcIcon.paintIcon(null, g, 0, 0);
   g.dispose();
   return new ImageIcon(op.filter(img, null));
 }
 public void loadImage(File f) {
   if (f == null) {
     thumbnail = null;
   } else {
     ImageIcon tmpIcon = new ImageIcon(f.getPath());
     if (tmpIcon.getIconWidth() > 90) {
       thumbnail =
           new ImageIcon(tmpIcon.getImage().getScaledInstance(90, -1, Image.SCALE_DEFAULT));
     } else {
       thumbnail = tmpIcon;
     }
   }
 }
  public void paint(Graphics g) {
    super.paint(g);
    if (thumbnail != null) {
      int x = getWidth() / 2 - thumbnail.getIconWidth() / 2;
      int y = getHeight() / 2 - thumbnail.getIconHeight() / 2;
      if (y < 0) {
        y = 0;
      }

      if (x < 5) {
        x = 5;
      }
      thumbnail.paintIcon(this, g, x, y);
    }
  }
Exemple #6
0
 // icon handling ------------------------------------------------------------
 // setzt anhand des Status (fieldState) das entsprechende Icon
 private final void setImage() {
   switch (fieldState) {
     case ERROR_STATE:
       currentImage = errorIcon.getImage();
       imageLabel.setIcon(errorIcon);
       imageLabel.setToolTipText("failure");
       textField.setMargin(bildInsets);
       break;
     case REQUIRE_STATE:
       currentImage = requireIcon.getImage();
       imageLabel.setIcon(requireIcon);
       imageLabel.setToolTipText("required");
       textField.setMargin(bildInsets);
       break;
     case WARNING_STATE:
       currentImage = warningIcon.getImage();
       imageLabel.setIcon(warningIcon);
       imageLabel.setToolTipText("warning");
       textField.setMargin(bildInsets);
       break;
     case CHECKED_STATE:
       currentImage = checkedIcon.getImage();
       imageLabel.setIcon(checkedIcon);
       imageLabel.setToolTipText("ok");
       textField.setMargin(bildInsets);
       break;
     case USER_STATE:
       currentImage = userIcon.getImage();
       imageLabel.setIcon(userIcon);
       imageLabel.setToolTipText("user message");
       textField.setMargin(bildInsets);
       break;
     default: //         case NOTHING_STATE :
       currentImage = null;
       imageLabel.setIcon(null);
       imageLabel.setToolTipText("");
       textField.setMargin(leerInsets);
   }
   repaint();
 }