当前位置: 首页>>代码示例>>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;未经允许,请勿转载。