/**
   * 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);
   }
 }
Beispiel #3
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();
 }
 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;
     }
   }
 }