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


Java ImageIcon類代碼示例

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


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

示例1: imshow

import javax.swing.ImageIcon; //導入依賴的package包/類
/**
 * Display image in a frame
 *
 * @param title
 * @param img
 */
public static void imshow(String title, Mat img) {
	 
    
    // Convert image Mat to a jpeg
    MatOfByte imageBytes = new MatOfByte();
    Highgui.imencode(".jpg", img, imageBytes);
    
    try {
        // Put the jpeg bytes into a JFrame window and show.
        JFrame frame = new JFrame(title);
        frame.getContentPane().add(new JLabel(new ImageIcon(ImageIO.read(new ByteArrayInputStream(imageBytes.toArray())))));
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
        frame.setLocation(30 + (windowNo*20), 30 + (windowNo*20));
        windowNo++;
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:fossasia,項目名稱:zooracle,代碼行數:27,代碼來源:OpenCVUtils.java

示例2: showSplash

import javax.swing.ImageIcon; //導入依賴的package包/類
/**
 * Method showSplash.
 */
private void showSplash() {
	splash = new JFrame();
	ImageIcon spl =
		new ImageIcon(App.class.getResource("resources/splash.png"));
	JLabel l = new JLabel();
	l.setSize(400, 300);
	l.setIcon(spl);
	splash.getContentPane().add(l);
	splash.setSize(400, 300);
	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	splash.setLocation(
		(screenSize.width - 400) / 2,
		(screenSize.height - 300) / 2);
	splash.setUndecorated(true);
	splash.setVisible(true);
}
 
開發者ID:ser316asu,項目名稱:SER316-Munich,代碼行數:20,代碼來源:App.java

示例3: getPriorityIcon

import javax.swing.ImageIcon; //導入依賴的package包/類
public static ImageIcon getPriorityIcon(Task t) {
    switch (t.getPriority()) {
    case Task.PRIORITY_NORMAL:
        return PR_NORMAL_ICON;
    case Task.PRIORITY_HIGHEST:
        return PR_HIGHEST_ICON;
    case Task.PRIORITY_HIGH:
        return PR_HIGH_ICON;
    case Task.PRIORITY_LOW:
        return PR_LOW_ICON;
    case Task.PRIORITY_LOWEST:
        return PR_LOWEST_ICON;
    }
    System.err.println("Problem finding priority icon");
    return null;
}
 
開發者ID:ser316asu,項目名稱:Neukoelln_SER316,代碼行數:17,代碼來源:TaskTreeTableCellRenderer.java

示例4: createPauseButton

import javax.swing.ImageIcon; //導入依賴的package包/類
protected void createPauseButton() {
    final JButton btPause = new JButton("Pause", new ImageIcon(RunCentralisedMAS.class.getResource("/images/resume_co.gif")));
    btPause.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (MASConsoleGUI.get().isPause()) {
                btPause.setText("Pause");
                MASConsoleGUI.get().setPause(false);
            } else {
                btPause.setText("Continue");
                MASConsoleGUI.get().setPause(true);
            }

        }
    });
    MASConsoleGUI.get().addButton(btPause);
}
 
開發者ID:nickrfer,項目名稱:code-sentinel,代碼行數:17,代碼來源:RunCentralisedMAS.java

示例5: btn_CarregarImagemActionPerformed

import javax.swing.ImageIcon; //導入依賴的package包/類
private void btn_CarregarImagemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_CarregarImagemActionPerformed
    // TODO add your handling code here:
    JFileChooser fc = new JFileChooser();
    FileFilter imageFilter = new FileNameExtensionFilter("Image files", ImageIO.getReaderFileSuffixes());
    fc.setFileFilter(imageFilter);
    int result = fc.showOpenDialog(null);
    if(result == JFileChooser.APPROVE_OPTION){
        try {
            String path = fc.getSelectedFile().getAbsolutePath();
            imagens.add(new ImageIcon(path));
            JOptionPane.showMessageDialog(this, "Imagem carregada com sucesso!");
        } catch(Exception e){
            JOptionPane.showMessageDialog(null, "Ocorreu um erro ao carregar a imagem!", "Erro", JOptionPane.ERROR_MESSAGE);
        }            
    }
}
 
開發者ID:Mentz,項目名稱:PPRCarTrade,代碼行數:17,代碼來源:TelaVenda.java

示例6: createMarketMenu

import javax.swing.ImageIcon; //導入依賴的package包/類
/**
 * Creates menu items for some goods in a market.
 *
 * @param marketLabel The {@code MarketLabel} to create entries for.
 */
private void createMarketMenu(MarketLabel marketLabel) {
    final AbstractGoods ag = marketLabel.getAbstractGoods();
    final Player player = freeColClient.getMyPlayer();

    this.setLabel(Messages.message("cargo"));
    JMenuItem name = new JMenuItem(
        Messages.getName(ag) + " (" + Messages.message("colopedia") + ")",
        new ImageIcon(
            gui.getImageLibrary().getSmallIconImage(ag.getType())));
    name.addActionListener((ActionEvent ae) -> {
            gui.showColopediaPanel(ag.getType().getId());
        });
    this.add(name);

    final Europe europe = this.freeColClient.getMyPlayer().getEurope();
    addMarketItems(ag, europe);

    if (!player.canTrade(ag.getType())) {
        addPayArrears(ag.getType());
    }
}
 
開發者ID:wintertime,項目名稱:FreeCol,代碼行數:27,代碼來源:QuickActionMenu.java

示例7: highlightAnnotation

import javax.swing.ImageIcon; //導入依賴的package包/類
/**
 * Highlight the given annotation
 *
 * @param annotation
 * @param point
 */
private void highlightAnnotation(final LabeledPath label, final GeoPoint point) {
	final ScreenAnnotation annotation = label.getAnnotation();
	if (_lastSelection != null) {
		final LabeledPath lastSelectedLabel = _lastSelection.getLeft();
		final ScreenAnnotation lastSelectedAnnotation = lastSelectedLabel.getAnnotation();
		final GeoPoint lastSelectedPoint = _lastSelection.getRight();
		if (_mapShowLabel) {
			lastSelectedAnnotation.setAttributes(createAnnotationAttr(false, lastSelectedPoint.getCountryFlag(IMAGE_RESOLUTION), getText(lastSelectedPoint)));
			lastSelectedAnnotation.setAlwaysOnTop(false);
		} else {
			_renderableLayer.removeRenderable(lastSelectedLabel);
		}
	}
	final ImageIcon image = point.getCountryFlag(IMAGE_RESOLUTION);
	final String text = getText(point);
	annotation.setAttributes(createAnnotationAttr(true, image, text));
	annotation.setAlwaysOnTop(true);
	if (!_mapShowLabel) {
		_renderableLayer.addRenderable(label);
		_controller.redraw();
	}
	_lastSelection = Pair.of(label, point);
}
 
開發者ID:leolewis,項目名稱:openvisualtraceroute,代碼行數:30,代碼來源:WWJPanel.java

示例8: getThumbnailIcon

import javax.swing.ImageIcon; //導入依賴的package包/類
private ImageIcon getThumbnailIcon() {
	if (this.thumbIcon == null) {
		if (this.isDirectory) {
			this.thumbIcon = getBigSystemIcon();
		} else {
			try {
				this.thumbIcon = new ImageIcon(Tools.getScaledInstance(this.file));
				if (this.thumbIcon == null) {
					this.thumbIcon = getBigSystemIcon();
				}
			} catch (Exception ex) {
				this.thumbIcon = getBigSystemIcon();
			}
		}
	}
	return this.thumbIcon;
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:18,代碼來源:Item.java

示例9: toGraphicFile

import javax.swing.ImageIcon; //導入依賴的package包/類
public void toGraphicFile(File file) throws IOException {
    // otherwise toolbar appears
    plotToolBar.setVisible(false);

    Image image = createImage(getWidth(), getHeight());
    paint(image.getGraphics());
    image = new ImageIcon(image).getImage();

    BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB);
    Graphics g = bufferedImage.createGraphics();
    g.drawImage(image, 0, 0, Color.WHITE, null);
    g.dispose();

    // make it reappear
    plotToolBar.setVisible(true);

    try {
        ImageIO.write((RenderedImage) bufferedImage, "PNG", file);
    } catch (IllegalArgumentException ex) {
    }
}
 
開發者ID:Cvarier,項目名稱:2D-Elliptic-Mesh-Generator,代碼行數:22,代碼來源:PlotPanel.java

示例10: getSmallSystemIcon

import javax.swing.ImageIcon; //導入依賴的package包/類
public static ImageIcon getSmallSystemIcon(Image img) throws Exception {
	if (img.getWidth(null) > 20 || img.getHeight(null) > 20) {
		if (img.getWidth(null) > img.getHeight(null)) {
			width = 18;
			height = img.getHeight(null) * 18 / img.getWidth(null);
		} else {
			height = 18;
			width = img.getWidth(null) * 18 / img.getHeight(null);
		}
	} else {
		return new ImageIcon(img);
	}

	dest = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
	dest2 = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);

	g = dest.getGraphics();
	g.drawImage(img, 1, 1, width, height, null);

	g.dispose();

	blurOperator.filter(dest, dest2);

	return new ImageIcon(dest2);
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:26,代碼來源:Tools.java

示例11: TabbedPaneDemo

import javax.swing.ImageIcon; //導入依賴的package包/類
public TabbedPaneDemo() {
    ImageIcon icon = new ImageIcon("images/middle.gif");
    JTabbedPane tabbedPane = new JTabbedPane();

    Component panel1 = makeTextPanel("Blah");
    tabbedPane.addTab("One", icon, panel1, "Does nothing");
    tabbedPane.setSelectedIndex(0);

    Component panel2 = makeTextPanel("Blah blah");
    tabbedPane.addTab("Two", icon, panel2, "Does twice as much nothing");

    Component panel3 = makeTextPanel("Blah blah blah");
    tabbedPane.addTab("Three", icon, panel3, "Still does nothing");

    Component panel4 = makeTextPanel("Blah blah blah blah");
    tabbedPane.addTab("Four", icon, panel4, "Does nothing at all");

    //Add the tabbed pane to this panel.
    setLayout(new GridLayout(1, 1));
    add(tabbedPane);
}
 
開發者ID:YunlongYang,項目名稱:LightSIP,代碼行數:22,代碼來源:TabbedPaneDemo.java

示例12: doLoadImages

import javax.swing.ImageIcon; //導入依賴的package包/類
final public void doLoadImages() {

		int intLiconFile =
							this.bolGresetPreferences ? Constants.intS_FILE_ICON_RESET_BW
														: this.bolGsavePreferences ? this.bolGcloseDialog ? Constants.intS_FILE_ICON_OK_BW
																											: Constants.intS_FILE_ICON_APPLY_BW
																					: this.bolGcloseDialog ? Constants.intS_FILE_ICON_CANCEL_BW
																											: Constants.intS_FILE_ICON_RESTORE_BW;
		final ImageIcon icoL = this.objGcontrolJFrame.getJuggleMasterPro().getImageIcon(intLiconFile, 2);

		intLiconFile =
						this.bolGresetPreferences ? Constants.intS_FILE_ICON_RESET
													: this.bolGsavePreferences ? this.bolGcloseDialog ? Constants.intS_FILE_ICON_OK
																										: Constants.intS_FILE_ICON_APPLY
																				: this.bolGcloseDialog ? Constants.intS_FILE_ICON_CANCEL
																										: Constants.intS_FILE_ICON_RESTORE;
		final ImageIcon icoLrollOver = this.objGcontrolJFrame.getJuggleMasterPro().getImageIcon(intLiconFile, 2);

		Tools.setIcons(this, icoL, icoLrollOver);
	}
 
開發者ID:jugglemaster,項目名稱:JuggleMasterPro,代碼行數:21,代碼來源:PreferencesDialogJButton.java

示例13: getListCellRendererComponent

import javax.swing.ImageIcon; //導入依賴的package包/類
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected,
		boolean cellHasFocus) {
	

	int selectedIndex = ((Integer) value).intValue();

	if (isSelected) {
		setBackground(list.getSelectionBackground());
		setForeground(list.getSelectionForeground());
	} else {
		setBackground(list.getBackground());
		setForeground(list.getForeground());
	}

	ImageIcon icon = iconArray[selectedIndex];
	setIcon(icon);
	
	return this;
}
 
開發者ID:Coder-ACJHP,項目名稱:Hotel-Properties-Management-System,代碼行數:21,代碼來源:LanguageCmbBox.java

示例14: getStatusIcon

import javax.swing.ImageIcon; //導入依賴的package包/類
public static ImageIcon getStatusIcon(Task t) {
    switch (t.getStatus(CurrentDate.get())) {
    case Task.ACTIVE:
        return TASK_ACTIVE_ICON;
    case Task.SCHEDULED:
        return TASK_SCHEDULED_ICON;
    case Task.DEADLINE:
        return TASK_DEADLINE_ICON;
    case Task.OVERDUE:
        return TASK_FAILED_ICON;
    case Task.COMPLETED:
        return TASK_COMPLETED_ICON;
    }
    System.err.println("Problem finding status icon");
    return null;
}
 
開發者ID:ser316asu,項目名稱:Dahlem_SER316,代碼行數:17,代碼來源:TaskTreeTableCellRenderer.java

示例15: getColorIcon

import javax.swing.ImageIcon; //導入依賴的package包/類
static Icon getColorIcon (java.awt.Color color) {
	BufferedImage image = new BufferedImage(32, 16, BufferedImage.TYPE_INT_RGB);
	java.awt.Graphics g = image.getGraphics();
	g.setColor(color);
	g.fillRect(1, 1, 30, 14);
	g.setColor(java.awt.Color.black);
	g.drawRect(0, 0, 31, 15);
	return new ImageIcon(image);
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:10,代碼來源:Hiero.java


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