當前位置: 首頁>>代碼示例>>Java>>正文


Java ImageIcon.paintIcon方法代碼示例

本文整理匯總了Java中javax.swing.ImageIcon.paintIcon方法的典型用法代碼示例。如果您正苦於以下問題:Java ImageIcon.paintIcon方法的具體用法?Java ImageIcon.paintIcon怎麽用?Java ImageIcon.paintIcon使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.ImageIcon的用法示例。


在下文中一共展示了ImageIcon.paintIcon方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setBackgroundImage

import javax.swing.ImageIcon; //導入方法依賴的package包/類
public void setBackgroundImage(Image image) {
  if (image != null) {
    final ImageIcon icon = new ImageIcon(image);
    logoSize = new Dimension(icon.getIconWidth(), icon.getIconHeight());
    final BufferedImage img =
      ImageUtils.createCompatibleTranslucentImage(logoSize.width,
                                                  logoSize.height);
    Graphics2D g = img.createGraphics();
    g.setColor(Color.white);
    g.fillRect(0, 0, icon.getIconWidth(), icon.getIconHeight());
    g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5F));
    icon.paintIcon(null, g, 0, 0);
    g.dispose();
    UIManager.put("wizard.sidebar.image", img); //$NON-NLS-1$
  }
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:17,代碼來源:WizardSupport.java

示例2: serialize

import javax.swing.ImageIcon; //導入方法依賴的package包/類
@Override
public void serialize(ImageIcon vi, JsonGenerator jgen, SerializerProvider provider)
    throws IOException, JsonProcessingException {
  synchronized (vi) {

    BufferedImage v = new BufferedImage(
      vi.getIconWidth(),
      vi.getIconHeight(),
      BufferedImage.TYPE_INT_RGB);
    Graphics g = v.createGraphics();
    // paint the Icon to the BufferedImage.
    vi.paintIcon(null, g, 0, 0);
    g.dispose();

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ImageIO.write(v, "png", baos);
    byte [] data = baos.toByteArray();
    jgen.writeStartObject();
    jgen.writeStringField("type",  "ImageIcon");
    jgen.writeObjectField("imageData", data);
    jgen.writeNumberField("width", v.getWidth());
    jgen.writeNumberField("height", v.getHeight());
    jgen.writeEndObject();
  }
}
 
開發者ID:twosigma,項目名稱:beaker-notebook-archive,代碼行數:26,代碼來源:ImageIconSerializer.java

示例3: toBufferedImage

import javax.swing.ImageIcon; //導入方法依賴的package包/類
public static BufferedImage toBufferedImage(final ImageIcon icon) {
    if (icon == null) return null;
    final int w = icon.getIconWidth(), h = icon.getIconHeight();
    final BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); 
    final Graphics g = bi.createGraphics();
    icon.paintIcon(null, g, 0,0);
    g.dispose();
    return bi;
}
 
開發者ID:iapafoto,項目名稱:DicomViewer,代碼行數:10,代碼來源:DataLoader.java


注:本文中的javax.swing.ImageIcon.paintIcon方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。