List of usage examples for javax.swing ImageIcon ImageIcon
public ImageIcon(byte[] imageData)
From source file:Main.java
public static void main(String[] argv) throws Exception { Image image = new ImageIcon("a.png").getImage(); if (image instanceof BufferedImage) { BufferedImage bimage = (BufferedImage) image; System.out.println(bimage.getColorModel().hasAlpha()); }/*from w w w. j a v a 2 s .co m*/ PixelGrabber pg = new PixelGrabber(image, 0, 0, 1, 1, false); try { pg.grabPixels(); } catch (InterruptedException e) { } ColorModel cm = pg.getColorModel(); System.out.println(cm.hasAlpha()); }
From source file:Main.java
public static void main(String[] args) throws Exception { ImageIcon ii = new ImageIcon("C:/Java_Dev/test.jpg"); BufferedImage bi = new BufferedImage(50, 50, BufferedImage.TYPE_INT_RGB); Graphics2D g2d = (Graphics2D) bi.createGraphics(); g2d.addRenderingHints(//ww w.j a v a2 s . c o m new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY)); boolean b = g2d.drawImage(ii.getImage(), 0, 0, 50, 50, null); System.out.println(b); ImageIO.write(bi, "jpg", new File("C:/Java_Dev/test.jpg")); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JCheckBox checkbox = new JCheckBox(); // Set the unselected state icon Icon unselDisIcon = new ImageIcon("nosel-dis-icon.gif"); checkbox.setDisabledIcon(unselDisIcon); // Set the selected state icon Icon selDisIcon = new ImageIcon("sel-dis-icon.gif"); checkbox.setDisabledSelectedIcon(selDisIcon); }
From source file:ImageTest.java
public static void main(String[] args) { ImagePanel panel = new ImagePanel(new ImageIcon("images/background.png").getImage()); JFrame frame = new JFrame(); frame.getContentPane().add(panel);//from w w w. ja v a2s. c om frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { JButton button = new JButton(); // Add rollover icon Icon rolloverIcon = new ImageIcon("r.gif"); button.setRolloverIcon(rolloverIcon); // Add pressed icon Icon pressedIcon = new ImageIcon("p.gif"); button.setPressedIcon(pressedIcon);/*w w w. j a v a2s .c om*/ // To remove rollover icon, set to null button.setRolloverIcon(null); // To remove pressed icon, set to null button.setPressedIcon(null); JOptionPane.showMessageDialog(null, button); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("DefaultButton"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Icon warnIcon = new ImageIcon("yourFile.gif"); JButton button2 = new JButton(warnIcon); frame.add(button2);//from w w w . j a va 2s . c om frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTabbedPane pane = new JTabbedPane(); JButton component = new JButton("button"); Icon icon = new ImageIcon("icon.gif"); pane.addTab("label", icon, component); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("DefaultButton"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Icon warnIcon = new ImageIcon("Warn.gif"); JButton button3 = new JButton("Warning", warnIcon); frame.add(button3);//www . ja v a 2s .co m frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTabbedPane pane = new JTabbedPane(); JButton component = new JButton("button"); int index = 1; pane.insertTab("label", new ImageIcon("icon.png"), component, "tooltip", index); }
From source file:Main.java
public static void main(String[] argv) throws Exception { // Retrieve the icon Icon icon = new ImageIcon("icon.gif"); // Create an action with an icon Action action = new AbstractAction("Button Label", icon) { // This method is called when the button is pressed public void actionPerformed(ActionEvent evt) { // Perform action }//from ww w .ja v a 2s . com }; // Create the button; the icon will appear to the left of the label JButton button = new JButton(action); }