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


Java ImageIcon.setImage方法代碼示例

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


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

示例1: setIconButtons

import javax.swing.ImageIcon; //導入方法依賴的package包/類
private void setIconButtons()

    {
        homeIcon = new ImageIcon("icon/home.png");
        Image icon = homeIcon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH);
        homeIcon.setImage(icon);
        home.setIcon(homeIcon);
        
        nextIcon = new ImageIcon("icon/next.png");
        icon = nextIcon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH);
        nextIcon.setImage(icon);
        next.setIcon(nextIcon);
        
        backIcon = new ImageIcon("icon/back.png");
        icon = backIcon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH);
        backIcon.setImage(icon);
        back.setIcon(backIcon);
        
        /*endIcon = new ImageIcon("icon/end.png");
        icon = endIcon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH);
        endIcon.setImage(icon);
        end.setIcon(endIcon);*/
    }
 
開發者ID:IngSW-unipv,項目名稱:Progetto-I,代碼行數:24,代碼來源:ExecutePage.java

示例2: getImage

import javax.swing.ImageIcon; //導入方法依賴的package包/類
ImageIcon getImage(URL base) {
    if (!loadedImage) {
        synchronized(this) {
            if (!loadedImage) {
                URL url = CSS.getURL(base, svalue);
                loadedImage = true;
                if (url != null) {
                    image = new ImageIcon();
                    Image tmpImg = Toolkit.getDefaultToolkit().createImage(url);
                    if (tmpImg != null) {
                        image.setImage(tmpImg);
                    }
                }
            }
        }
    }
    return image;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:19,代碼來源:CSS.java

示例3: setIconButtons

import javax.swing.ImageIcon; //導入方法依賴的package包/類
private void setIconButtons()
{
    homeIcon = new ImageIcon("icon/home.png");
    Image icon = homeIcon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH);
    homeIcon.setImage(icon);
    home.setIcon(homeIcon);
    
    nextIcon = new ImageIcon("icon/next.png");
    icon = nextIcon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH);
    nextIcon.setImage(icon);
    next.setIcon(nextIcon);
    
    backIcon = new ImageIcon("icon/back.png");
    icon = backIcon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH);
    backIcon.setImage(icon);
    back.setIcon(backIcon);
    
    endIcon = new ImageIcon("icon/end.png");
    icon = endIcon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH);
    endIcon.setImage(icon);
    end.setIcon(endIcon);
}
 
開發者ID:IngSW-unipv,項目名稱:Progetto-I,代碼行數:23,代碼來源:ExecutePage.java

示例4: setIconPath

import javax.swing.ImageIcon; //導入方法依賴的package包/類
/**
 * 按圖片路徑設置菜單圖片
 * 
 * @param i_IconPath
 * @throws Exception
 */
public void setIconPath(String i_IconPath) throws Exception
{
	ImageIcon v_Image = new ImageIcon(new URL(i_IconPath));
	
	v_Image.setImage(v_Image.getImage().getScaledInstance(17 ,17 ,1));
	
	super.setIcon(v_Image);
}
 
開發者ID:HY-ZhengWei,項目名稱:hy.common.ui,代碼行數:15,代碼來源:JMenuItem.java

示例5: Inicial

import javax.swing.ImageIcon; //導入方法依賴的package包/類
/**
 * Creates new form Main
 */
public Inicial() {
    initComponents();
    this.setLocationRelativeTo(null);

    setIcon();

    ImageIcon img = new javax.swing.ImageIcon("C:\\Users\\Public\\Pictures\\telaFundo.png");
    img.setImage(img.getImage().getScaledInstance(617, 447, 100));

    lbl_imagem.setIcon(img);
}
 
開發者ID:wesleyreis1808,項目名稱:projetomcdonalds,代碼行數:15,代碼來源:Inicial.java

示例6: loadImages

import javax.swing.ImageIcon; //導入方法依賴的package包/類
private void loadImages() {
	String[] imageNames = { IMG_LOGOPOLI, IMG_SUITEICON };
	//load each image referenced in the above array
	for (String imageName : imageNames) {
		ImageIcon img = JMTImageLoader.loadImage(imageName);
		if (imageName.equals(IMG_LOGOPOLI)) {
			Image imgSmall = img.getImage().getScaledInstance(400, (150 * 400) / 739, Image.SCALE_SMOOTH);
			img.setImage(imgSmall);
		}
		imageIcons.put(imageName, img);
	}
}
 
開發者ID:HOMlab,項目名稱:QN-ACTR-Release,代碼行數:13,代碼來源:AlphaNumStartScreen.java

示例7: loadImages

import javax.swing.ImageIcon; //導入方法依賴的package包/類
private void loadImages() {
	String[] imageNames = { IMG_LOGOPOLI, IMG_JMODELICON, IMG_JMVAICON, IMG_JABAICON, IMG_JMCHICON, IMG_JWATICON, IMG_JSIMICON, IMG_SUITEICON };
	//load each image referenced in the above array
	for (String imageName : imageNames) {
		ImageIcon img = JMTImageLoader.loadImage(imageName);
		if (imageName.equals(IMG_LOGOPOLI)) {
			//                Image imgSmall = img.getImage().getScaledInstance(400,(150*(400))/739,Image.SCALE_SMOOTH);
			Image imgSmall = img.getImage().getScaledInstance(100, 100, Image.SCALE_SMOOTH);
			img.setImage(imgSmall);
		}
		imageIcons.put(imageName, img);
	}
}
 
開發者ID:HOMlab,項目名稱:QN-ACTR-Release,代碼行數:14,代碼來源:UniqueStartScreen.java

示例8: executeWithUnitOutForAnimation

import javax.swing.ImageIcon; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
public void executeWithUnitOutForAnimation(JLabel unitLabel) {
    final GUI gui = getGUI();

    // Tile position should now be valid.
    if (gui.getTilePosition(this.tile) == null) {
        logger.warning("Failed attack animation for " + this.unit
            + " at tile: " + this.tile);
        return;
    }

    final Rectangle rect = gui.getTileBounds(this.tile);
    final ImageIcon icon = (ImageIcon)unitLabel.getIcon();
    for (AnimationEvent event : animation) {
        long time = System.nanoTime();
        if (event instanceof ImageAnimationEvent) {
            final ImageAnimationEvent ievent = (ImageAnimationEvent)event;
            Image image = ievent.getImage();
            if (mirror) {
                // FIXME: Add mirroring functionality to SimpleZippedAnimation
                image = ImageLibrary.createMirroredImage(image);
            }
            icon.setImage(image);
            gui.paintImmediatelyCanvasIn(rect);
            time = ievent.getDurationInMs()
                - (System.nanoTime() - time) / 1000000;
            if (time > 0) Utils.delay(time, "Animation delayed.");
        }
    }
    gui.refresh();
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:34,代碼來源:UnitImageAnimation.java

示例9: setStartIcon

import javax.swing.ImageIcon; //導入方法依賴的package包/類
private void setStartIcon()
{
    startIcon = new ImageIcon("icon/next.png");
    Image icon = startIcon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH);
    startIcon.setImage(icon);
    start.setIcon(startIcon);
}
 
開發者ID:IngSW-unipv,項目名稱:Progetto-I,代碼行數:8,代碼來源:Home.java

示例10: setStartIcon

import javax.swing.ImageIcon; //導入方法依賴的package包/類
private void setStartIcon()
{
    startIcon = new ImageIcon("icon/start.png");
    Image icon = startIcon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH);
    startIcon.setImage(icon);
    start.setIcon(startIcon);
}
 
開發者ID:IngSW-unipv,項目名稱:Progetto-I,代碼行數:8,代碼來源:HomePage.java

示例11: refreshViewer

import javax.swing.ImageIcon; //導入方法依賴的package包/類
private static void refreshViewer(Image img, AtomicInteger zoomX, AtomicInteger zoomY, ImageIcon icon, Frame frame) {
    //System.err.println(zoomX);
    //System.err.println(zoomY);
    Image newImage;
    if (zoomX.get() == 1 && zoomY.get() == 1) {
        newImage = img;
    } else {
        newImage = img.getScaledInstance((int)(img.getWidth(frame) * Math.pow(2, zoomX.get())),
                                         (int)(img.getHeight(frame) * Math.pow(2, zoomY.get())),
                                         Image.SCALE_SMOOTH);
    }
    icon.setImage(newImage);
    frame.repaint();
}
 
開發者ID:tberg12,項目名稱:klavier,代碼行數:15,代碼來源:MatrixVis.java

示例12: afficheRune

import javax.swing.ImageIcon; //導入方法依賴的package包/類
private void afficheRune(String url){
   java.net.URL imageURL = Main.class.getResource(url);
   ImageIcon icon = new ImageIcon(imageURL);
   if (url.equals("/images/stele.png")){
       java.awt.Image imagePhoto=icon.getImage();
       imagePhoto=imagePhoto.getScaledInstance(88,112,java.awt.Image.SCALE_SMOOTH);
       icon.setImage(imagePhoto);
   }
   runeLbl.setIcon(icon);
}
 
開發者ID:Denis-Bonnot-project,項目名稱:Jeu-de-runes,代碼行數:11,代碼來源:Rune.java


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