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) 

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 {
    Icon icon = new ImageIcon("icon.gif");

    JLabel label = new JLabel("Text Label", icon, JLabel.CENTER);

    // a label with only an icon
    label = new JLabel(icon);

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    final ImageIcon icon = new ImageIcon(new URL("http://www.java2s.com/style/download.png"));
    JOptionPane.showMessageDialog(null, "Blah blah blah", "About", JOptionPane.INFORMATION_MESSAGE, icon);
}

From source file:Main.java

public static void main(String[] args) {
    Icon icon = new ImageIcon("yourImage.png");
    JLabel label = new JLabel("Full Name :", icon, JLabel.LEFT);

    JOptionPane.showMessageDialog(null, label);

}

From source file:Main.java

public static void main(String[] args) {
    Icon icon = new ImageIcon("yourImage.png");
    JLabel label = new JLabel("Full Name :", icon, JLabel.LEFT);

    label.setIcon(new ImageIcon("b.png"));

    JOptionPane.showMessageDialog(null, label);

}

From source file:Main.java

public static void main(final String args[]) {
    Icon icon = new ImageIcon("dog.jpg");
    JButton button = new JButton(icon);

    JOptionPane.showMessageDialog(null, button);
}

From source file:Main.java

public static void main(final String args[]) {
    Icon icon = new ImageIcon("dog.jpg");
    JButton button = new JButton("Dog", icon);

    JOptionPane.showMessageDialog(null, button);
}

From source file:Main.java

public static void main(String[] argv) {
    ImageIcon icon = new ImageIcon("image.gif");
    MatteBorder matteBorder = (MatteBorder) BorderFactory.createMatteBorder(-1, -1, -1, -1, icon);
    JLabel component = new JLabel("label");
    component.setBorder(matteBorder);/*from w  ww.  jav  a  2s .  co m*/

}

From source file:Main.java

public static void main(String[] args) throws Exception {

    ImageIcon icon = new ImageIcon(new URL("http://www.java2s.com/style/download.png"));

    UIManager.put("OptionPane.informationIcon", icon);

    JOptionPane.showMessageDialog(null, "Hello!");
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Image image = new ImageIcon("image.gif").getImage();

    BufferedImage bimage = new BufferedImage(image.getWidth(null), image.getHeight(null),
            BufferedImage.TYPE_INT_RGB);

    Graphics2D g = bimage.createGraphics();
    g.drawImage(image, 0, 0, null);//from  ww  w .  j av a2 s .c o  m
    g.dispose();
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    JCheckBox checkbox = new JCheckBox();

    Icon rollIcon = new ImageIcon("roll-icon.gif");
    checkbox.setRolloverIcon(rollIcon);//  w w  w.  jav a  2s.c  om

}