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 { JCheckBox checkbox = new JCheckBox(); Icon pressedIcon = new ImageIcon("pres-icon.gif"); checkbox.setPressedIcon(pressedIcon); }
From source file:Main.java
public static void main(final String args[]) { JButton button = new JButton(); Icon pressedIcon = new ImageIcon("pres-icon.gif"); button.setPressedIcon(pressedIcon);//from w ww. jav a 2 s .com JOptionPane.showMessageDialog(null, button); }
From source file:StringArrayOptionPopups.java
public static void main(String[] a) { JFrame frame = new JFrame(); Icon blueIcon = new ImageIcon("yourFile.gif"); Object stringArray[] = { "Do It", "No Way" }; JOptionPane.showOptionDialog(frame, "Continue printing?", "Select an Option", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, blueIcon, stringArray, stringArray[0]); }
From source file:AddingIconsToOptionPopups.java
public static void main(String[] a) { JFrame frame = new JFrame(); Icon greenIcon = new ImageIcon("yourFile.gif"); Icon redIcon = new ImageIcon(""); Object iconArray[] = { greenIcon, redIcon }; JOptionPane.showOptionDialog(frame, "Continue printing?", "Select an Option", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, iconArray, iconArray[1]); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JButton button = new JButton(); // Add or change the icon; it will appear to the left of the text button.setIcon(new ImageIcon("icon.gif")); // Set to null to remove icon button.setIcon(null);//from www. j ava 2 s. c om }
From source file:Main.java
public static void main(String[] argv) throws Exception { 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);//from ww w. ja va2 s . c o m // To remove rollover icon, set to null button.setRolloverIcon(null); // To remove pressed icon, set to null button.setPressedIcon(null); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Image img = new ImageIcon("test.png").getImage(); BufferedImage bufferedImage = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_RGB); Graphics g = bufferedImage.createGraphics(); g.drawImage(img, 0, 0, null);//from ww w.ja v a 2s. c o m g.dispose(); ImageIO.write(bufferedImage, "png", new File("a.png")); }
From source file:ComplexMessageDemo.java
public static void main(String[] a) { Object complexMsg[] = { "Above Message", new ImageIcon("yourFile.gif"), new JButton("Hello"), new JSlider(), new ImageIcon("yourFile.gif"), "Below Message" }; JOptionPane optionPane = new JOptionPane(); optionPane.setMessage(complexMsg);//from www .j a v a2 s .com optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE); JDialog dialog = optionPane.createDialog(null, "Width 100"); dialog.setVisible(true); }
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().getNumColorComponents()); }/* w w w. j a v a2s .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.getNumColorComponents()); }
From source file:ImageTest.java
public static void main(String[] args) { JPanel panel = new JPanel(); ImageLabel label = new ImageLabel(new ImageIcon("images/reactor.png")); label.setLocation(29, 37);//from w w w . j a v a 2 s. c om panel.add(label); JFrame frame = new JFrame(); frame.getContentPane().add(panel); frame.pack(); frame.setVisible(true); }