Java 8 ImageIcon - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 ImageIcon class.

This code example shows how to use the following methods:getIconHeight, getIconWidth, getImage
This code example shows how to use the following methods:
import javax.swing.ImageIcon;
 
public abstract class ZLSwingIconUtil { 
	public static ImageIcon getIcon(String fileName) {
		URL iconURL = ZLSwingIconUtil.class.getClassLoader().getResource(fileName);
		return (iconURL != null) ? new ImageIcon(iconURL) : new ImageIcon(fileName);
	} 
} 
7
CodeRank
This code example shows how to use the following methods:getIconHeight, getIconWidth
	private Font versionTextFont = null;
 
	public FreeplaneSplashModern(final JFrame frame) {
		super(frame);
		splashResource = ResourceController.getResourceController().getResource("/images/Freeplane_splash.png");
		splashImage = new ImageIcon(splashResource);
		setBackground(new Color(0x57, 0xbf, 0x5e));
		final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		final Dimension labelSize = new Dimension(splashImage.getIconWidth(), splashImage.getIconHeight());
		setLocation(screenSize.width / 2 - (labelSize.width / 2), screenSize.height / 2 - (labelSize.height / 2));
		setSize(labelSize);
		RootPane rootPane = new RootPane();
		rootPane.setSize(labelSize);
		setRootPane(rootPane);
	} 
 
	private void createVersionTextFont() { 
		if(versionTextFont != null){
			return; 
		} 
7
CodeRank
This code example shows how to use the following methods:
This code example shows how to use the following methods:getIconHeight, getIconWidth, getImage
This code example shows how to use the following methods:getIconHeight, getIconWidth, getImage
This code example shows how to use the following methods:getIconHeight, getIconWidth, getImage
    if(leftImage == null) return rightImage;
    if(rightImage == null) return leftImage;
 
    // Check the cache to see if there's a set of combination icons with 
    // this as the leftmost image. 
    Map<Object, ImageIcon> combos = _icons.get(leftImage);
    // If we've never cached anything for this leftImage before, create 
    // a map of (_icons[left])[right] -> combined icon. 
    if(combos == null) { 
      ImageIcon new_icon = appendIcons(leftImage, rightImage);
      combos = new HashMap<Object, ImageIcon>();
      combos.put(rightImage, new_icon);
      _icons.put(leftImage, combos);
      return new_icon;
    } 
 
    // We know we've got a combination map, so get the combination for the 
    // rightside icon. 
    ImageIcon old_icon = combos.get(rightImage);
    // If we didn't have a combination for that pair, build it. 

7
CodeRank
This code example shows how to use the following methods:getIconHeight, getIconWidth
 
  private void chooseImage() throws MalformedURLException {
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.showOpenDialog(this);
    Path file = fileChooser.getSelectedFile().toPath();
    Icon imageIcon = new ImageIcon(file.toUri().toURL());
    setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight() + 100);
    imageLabel.setIcon(imageIcon);
    String decodeText = getDecodeText(file);
    textArea.setText(decodeText);
  } 
 
  private static String getDecodeText(Path file) {
    BufferedImage image;
    try { 
      image = ImageReader.readImage(file.toUri());
    } catch (IOException ioe) {
      return ioe.toString();
    } 
    LuminanceSource source = new BufferedImageLuminanceSource(image);
7
CodeRank
This code example shows how to use the following methods:getIconHeight, getIconWidth, getImage
        x += (bounds.width - w) / 2;
        y += (bounds.height - h) / 2;
 
        g.drawImage(getImage()/*scaledImage*/, x, y, w, h, getImageObserver());
 
        int oiw = (int) (ICON_STATIC.getIconWidth() * s);
        int oih = (int) (ICON_STATIC.getIconHeight() * s);
 
        if ((m_flags & FLAG_CONSTRUCTOR) > 0)
        { 
 
            g.drawImage(ICON_CONSTRUCTOR.getImage(), x + oiw, y + oih, oiw, oih, getImageObserver());
        } 
        if ((m_flags & FLAG_STATIC) > 0)
        { 
            g.drawImage(ICON_STATIC.getImage(), x, y, oiw, oih, getImageObserver());
        } 
        if ((m_flags & FLAG_FINAL) > 0)
        { 
            g.drawImage(ICON_FINAL.getImage(), x + oiw, y, oiw, oih, getImageObserver());
        } 
6
CodeRank
This code example shows how to use the following methods:
        } 
 
        // due to an issue with ImageIO and mixed signed code 
        // we are now using good oldfashioned ImageIcon to load 
        // images and the paint it on top of a new BufferedImage 
        Image img = new ImageIcon(url).getImage();
        BufferedImage bufferedImage = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_RGB);
        Graphics g = bufferedImage.getGraphics();
        g.drawImage(img, 0, 0, null);
        g.dispose();
 
        return bufferedImage;
    } 
} 
7
CodeRank
See Code Examples for Java 8 ImageIcon Methods: