List of usage examples for javax.swing ImageIcon ImageIcon
public ImageIcon(byte[] imageData)
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")); JLabel iconLabel = new JLabel(icon); JPanel iconPanel = new JPanel(new GridBagLayout()); iconPanel.add(iconLabel);//from w w w . ja va 2 s . c om JPanel textPanel = new JPanel(new GridLayout(0, 1)); for (int i = 0; i < 15; i++) { textPanel.add(new JLabel("Hello")); } JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.add(textPanel); mainPanel.add(iconPanel, BorderLayout.WEST); JOptionPane.showMessageDialog(null, mainPanel, "Center Image Dialog", JOptionPane.PLAIN_MESSAGE); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); ImageIcon ii = new ImageIcon("largeJava2sLogo.gif"); JScrollPane jsp = new JScrollPane(new ScrollableLabel(ii)); f.getContentPane().add(jsp);/*from w ww . ja v a2s . co m*/ f.setSize(300, 250); f.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { ImageIcon iconA = new ImageIcon("IconA.gif"); ImageIcon iconDiable = new ImageIcon("disable.gif"); ImageIcon iconOver = new ImageIcon("over.gif"); ImageIcon iconPressed = new ImageIcon("IconAPressed.gif"); final JButton jbtnA = new JButton("Alpha", iconA); JFrame jfrm = new JFrame(); jfrm.setLayout(new FlowLayout()); jfrm.setSize(300, 300);//w ww . j a va 2 s . c om jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jbtnA.setRolloverIcon(iconOver); jbtnA.setPressedIcon(iconPressed); jbtnA.setDisabledIcon(iconDiable); jfrm.getRootPane().setDefaultButton(jbtnA); jbtnA.setMnemonic(KeyEvent.VK_A); jbtnA.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { System.out.println("Alpha pressed. Beta is enabled."); jbtnA.setEnabled(!jbtnA.isEnabled()); } }); jfrm.add(jbtnA); jfrm.setVisible(true); }
From source file:Main.java
public static void main(String[] args) throws Exception { File file = new File(args[0]); sun.awt.shell.ShellFolder sf = sun.awt.shell.ShellFolder.getShellFolder(file); Icon icon = new ImageIcon(sf.getIcon(true)); System.out.println("type = " + sf.getFolderType()); JLabel label = new JLabel(icon); JFrame frame = new JFrame(); frame.getContentPane().add(label);/*www.java 2 s.c om*/ frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) throws IOException { final int SCALE = 2; Image img = new ImageIcon(new URL("http://www.java2s.com/style/download.png")).getImage(); BufferedImage bi = new BufferedImage(SCALE * img.getWidth(null), SCALE * img.getHeight(null), BufferedImage.TYPE_INT_ARGB); Graphics2D grph = (Graphics2D) bi.getGraphics(); grph.scale(SCALE, SCALE);/* w w w. j a va 2 s .c o m*/ grph.drawImage(img, 0, 0, null); grph.dispose(); ImageIO.write(bi, "png", new File("double_size.png")); }
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ImageIcon icon = new ImageIcon("yourFile.gif"); Image normalImage = icon.getImage(); Image grayImage = GrayFilter.createDisabledImage(normalImage); Icon warningIcon = new ImageIcon(grayImage); JLabel warningLabel = new JLabel(warningIcon); JLabel label3 = new JLabel("Warning", icon, JLabel.CENTER); frame.add(warningLabel, "Center"); frame.add(label3, "South"); frame.setSize(300, 200);/*from www .j av a 2 s . c o m*/ frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { JButton button = new JButton(); // Icon will appear gray button.setEnabled(false);/* w ww . j a va 2s . co m*/ // Set a disabled version of icon Icon disabledIcon = new ImageIcon("d.gif"); button.setDisabledIcon(disabledIcon); // To remove the disabled version of the icon, set to null button.setDisabledIcon(null); button.setDisabledIcon(new ImageIcon("icon.gif")); JOptionPane.showMessageDialog(null, button); }
From source file:Main.java
public static void main(String[] argv) throws Exception { ImageSelection imgSel = new ImageSelection(new ImageIcon("a.png").getImage()); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(imgSel, null); }
From source file:CornerSample.java
public static void main(String args[]) { JFrame frame = new JFrame("Cornering Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Icon miniLogo = new ImageIcon("logo.gif"); Icon acrossLogo = new ImageIcon("logo-across.jpg"); Icon downLogo = new ImageIcon("logo-down.jpg"); Icon bookCover = new ImageIcon("puzzlebook.jpg"); JLabel logoLabel = new JLabel(miniLogo); JLabel columnLabel = new JLabel(acrossLogo); JLabel rowLabel = new JLabel(downLogo); JLabel coverLabel = new JLabel(bookCover); JScrollPane scrollPane = new JScrollPane(coverLabel); scrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, logoLabel); scrollPane.setColumnHeaderView(columnLabel); scrollPane.setRowHeaderView(rowLabel); frame.getContentPane().add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 200);//from www . j av a 2s . c om frame.setVisible(true); }
From source file:Main.java
public static void main(String avg[]) throws Exception { BufferedImage img = ImageIO.read(new URL("http://www.java2s.com/style/download.png")); ImageIcon icon = new ImageIcon(img); JFrame frame = new JFrame(); frame.setLayout(new FlowLayout()); frame.setSize(200, 300);//from w ww . ja va 2s. com JLabel lbl = new JLabel(); lbl.setIcon(icon); frame.add(lbl); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }