List of usage examples for javax.swing ImageIcon setImageObserver
public void setImageObserver(ImageObserver observer)
From source file:Main.java
static ImageIcon makeImageIcon(URL url, JComboBox combo, int row) { ImageIcon icon = new ImageIcon(url); icon.setImageObserver(new ImageObserver() { public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h) { if (combo.isShowing() && (infoflags & (FRAMEBITS | ALLBITS)) != 0) { if (combo.getSelectedIndex() == row) { combo.repaint();/* w w w. j a v a 2 s .c o m*/ } BasicComboPopup p = (BasicComboPopup) combo.getAccessibleContext().getAccessibleChild(0); JList list = p.getList(); if (list.isShowing()) { list.repaint(list.getCellBounds(row, row)); } } return (infoflags & (ALLBITS | ABORT)) == 0; }; }); return icon; }
From source file:musiccrawler.App.java
private JPanel loadingPanel() { JPanel panel = new JPanel(); BoxLayout layoutMgr = new BoxLayout(panel, BoxLayout.PAGE_AXIS); panel.setLayout(layoutMgr);/*from w w w .j av a 2s. c om*/ ClassLoader cldr = this.getClass().getClassLoader(); java.net.URL imageURL = cldr.getResource("image/ajax-loader.gif"); ImageIcon imageIcon = new ImageIcon(imageURL); JLabel iconLabel = new JLabel(); iconLabel.setIcon(imageIcon); imageIcon.setImageObserver(iconLabel); JLabel label = new JLabel("Loading..."); panel.add(iconLabel); panel.add(label); return panel; }