コード例 #1
0
  /**
   * 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();
  }
コード例 #2
0
 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);
   }
 }
コード例 #3
0
 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));
 }
コード例 #4
0
 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;
     }
   }
 }
コード例 #5
0
  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);
    }
  }
コード例 #6
0
ファイル: TLangTextField.java プロジェクト: ambro2/popeye
 // 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();
 }