Package javax.swing

Examples of javax.swing.Icon


      Transferable transferable = createTransferable(component);
      if (transferable != null) {
        this.autoscrolls = component.getAutoscrolls();
        component.setAutoscrolls(false);
        try {
          Icon icon = getVisualRepresentation(transferable);
          if (icon != null) {
            // Create a half transparent drag image from icon
            BufferedImage image = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
            Graphics2D g2D = (Graphics2D)image.getGraphics();
            g2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.66f));
            icon.paintIcon(component, g2D, 0, 0);
            g2D.dispose();
           
            ev.startDrag(null, image, new Point(12, 24),  transferable, this);
          } else {
            // Force the use of an empty image otherwise Mac OS X uses a grey rectangle
View Full Code Here


    Map<Integer, Icon> contentIcons = this.icons.get(content);
    if (contentIcons == null) {
      contentIcons = Collections.synchronizedMap(new HashMap<Integer, Icon>());
      this.icons.put(content, contentIcons);
    }
    Icon icon = contentIcons.get(height);
    if (icon == null) {
      // Tolerate null content
      if (content == null) {
        icon = new Icon() {
          public void paintIcon(Component c, Graphics g, int x, int y) {
          }
         
          public int getIconWidth() {
            return Math.max(0, height);
View Full Code Here

    } catch (UnavailableServiceException ex) {
      // Too bad : service is unavailable            
    }
   
    String title = this.preferences.getLocalizedString(HomePane.class, "about.title");
    Icon   icon  = new ImageIcon(HomePane.class.getResource(
        this.preferences.getLocalizedString(HomePane.class, "about.icon")));
    JOptionPane.showMessageDialog(this, messagePane, title, 
        JOptionPane.INFORMATION_MESSAGE, icon);
  }
View Full Code Here

            TextureImage wallPattern = (TextureImage)value;
            final Component component = super.getListCellRendererComponent(
                list, "", index, isSelected, cellHasFocus);
            final BufferedImage patternImage = SwingTools.getPatternImage(
                wallPattern, list.getBackground(), list.getForeground());
            setIcon(new Icon() {
                public int getIconWidth() {
                  return patternImage.getWidth() * 4 + 1;
                }
         
                public int getIconHeight() {
View Full Code Here

 
  /**
   * Returns the image used in case of an error.
   */
  private BufferedImage getErrorImage() {
    Icon errorIcon = IconManager.getInstance().getErrorIcon(16);
    BufferedImage errorImage = new BufferedImage(
        errorIcon.getIconWidth(), errorIcon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2D = (Graphics2D)errorImage.getGraphics();
    errorIcon.paintIcon(this, g2D, 0, 0);
    g2D.dispose();
    return errorImage;
  }
View Full Code Here

          public void propertyChange(PropertyChangeEvent ev) {
            repaint();
          }
        });
   
    setIcon(new Icon() {
        public int getIconWidth() {
          return iconHeight;
        }
 
        public int getIconHeight() {
          return iconHeight;
        }
 
        public void paintIcon(Component c, Graphics g, int x, int y) {
          g.setColor(Color.BLACK);
          g.drawRect(x + 2, y + 2, iconHeight - 5, iconHeight - 5);
          HomeTexture texture = controller.getTexture();
          if (texture != null) {
            Icon icon = IconManager.getInstance().getIcon(
                texture.getImage(), iconHeight - 6, TextureChoiceComponent.this);
            if (icon.getIconWidth() != icon.getIconHeight()) {
              Graphics2D g2D = (Graphics2D)g;
              AffineTransform previousTransform = g2D.getTransform();
              g2D.translate(x + 3, y + 3);
              g2D.scale((float)icon.getIconHeight() / icon.getIconWidth(), 1);
              icon.paintIcon(c, g2D, 0, 0);
              g2D.setTransform(previousTransform);
            } else {
              icon.paintIcon(c, g, x + 3, y + 3);
            }
          }
        }
      });
   
View Full Code Here

          private int lastIconWidth;

          @Override
          protected void paintComponent(Graphics g) {
            // If icon width changed after its loading 
            Icon icon = getIcon();
            if (icon != null
                && icon.getIconWidth() != this.lastIconWidth) {
              // Revalidate label to layout again texture panel
              this.lastIconWidth = icon.getIconWidth();
              revalidate();
            } else {
              super.paintComponent(g);
            }
          }
         
          @Override
          public void setIcon(Icon icon) {
            if (icon != null) {
              this.lastIconWidth = icon.getIconWidth();
            }
            super.setIcon(icon);
          }
        };
      // Update edited texture in texture panel
View Full Code Here

      if (previewTexture != null) {
        this.texturePreviewLabel.setIcon(
            IconManager.getInstance().getIcon(previewTexture.getImage(), PREVIEW_ICON_HEIGHT, this.texturePreviewLabel));
      } else {
        // Preview a dummy empty icon
        this.texturePreviewLabel.setIcon(new Icon() {
          public int getIconHeight() {
            return PREVIEW_ICON_HEIGHT;
          }
         
          public int getIconWidth() {
View Full Code Here

  public ColorButton() {
    JLabel colorLabel = new JLabel("Color");
    Dimension iconDimension = colorLabel.getPreferredSize();
    final int iconWidth = iconDimension.width;
    final int iconHeight = iconDimension.height;
    setIcon(new Icon() {
      public int getIconWidth() {
        return iconWidth;
      }

      public int getIconHeight() {
View Full Code Here

        final CatalogTexture texture = (CatalogTexture)value;
        value = texture.getName();
        value = texture.getCategory().getName() + " - " + value;
        Component component = super.getListCellRendererComponent(
            list, value, index, isSelected, cellHasFocus);
        setIcon(new Icon() {
            public int getIconWidth() {
              return 16;
            }
     
            public int getIconHeight() {
              return 16;
            }
     
            public void paintIcon(Component c, Graphics g, int x, int y) {
              Icon icon = IconManager.getInstance().getIcon(
                  texture.getImage(), getIconHeight(), list);
              if (icon.getIconWidth() != icon.getIconHeight()) {
                Graphics2D g2D = (Graphics2D)g;
                AffineTransform previousTransform = g2D.getTransform();
                g2D.translate(x, y);
                g2D.scale((float)icon.getIconHeight() / icon.getIconWidth(), 1);
                icon.paintIcon(c, g2D, 0, 0);
                g2D.setTransform(previousTransform);
              } else {
                icon.paintIcon(c, g, x, y);
              }
            }
          });
        setFont(texture.isModifiable() ? this.modifiablePieceFont : this.defaultFont);
        return component;
View Full Code Here

TOP

Related Classes of javax.swing.Icon

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.