Example usage for javax.swing ImageIcon ImageIcon

List of usage examples for javax.swing ImageIcon ImageIcon

Introduction

In this page you can find the example usage for javax.swing ImageIcon ImageIcon.

Prototype

public ImageIcon(byte[] imageData, String description) 

Source Link

Document

Creates an ImageIcon from an array of bytes which were read from an image file containing a supported image format, such as GIF, JPEG, or (as of 1.3) PNG.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    File file = new File("filename.txt");
    ShellFolder sf = ShellFolder.getShellFolder(file);

    Icon icon = new ImageIcon(sf.getIcon(true), sf.getFolderType());

}

From source file:components.LabelDemo.java

/** Returns an ImageIcon, or null if the path was invalid. */
protected static ImageIcon createImageIcon(String path, String description) {
    java.net.URL imgURL = LabelDemo.class.getResource(path);
    if (imgURL != null) {
        return new ImageIcon(imgURL, description);
    } else {/*from w w  w.ja v a2s  . c om*/
        System.err.println("Couldn't find file: " + path);
        return null;
    }
}

From source file:com.validation.manager.core.tool.Tool.java

public static ImageIcon createImageIcon(String path, String description, Class relativeTo) {
    URL imgURL = relativeTo == null ? Tool.class.getResource(path) : relativeTo.getResource(path);
    return imgURL == null ? null : new ImageIcon(imgURL, description);
}

From source file:SwingLabelDemo.java

/** Returns an ImageIcon, or null if the path was invalid. */
protected static ImageIcon createImageIcon(String path, String description) {
    java.net.URL imgURL = SwingLabelDemo.class.getResource(path);
    if (imgURL != null) {
        return new ImageIcon(imgURL, description);
    } else {/*from w  w  w .ja  va  2s  . c om*/
        System.err.println("Couldn't find file: " + path);
        return null;
    }
}