public ChatWindowTab(String title, JTabbedPane parent, ChatWindow owner) { // JPanel für Tabbeschriftung erzeugen und durchsichtig machen: this.parent = parent; this.owner = owner; ((FlowLayout) this.getLayout()).setHgap(5); this.setOpaque(false); // TitelLabel für Tabbeschriftung erzeugen: lblTitle = new JLabel(title); // MouseListener zu JLabel (lblTitle) hinzufügen: lblTitle.addMouseListener(this); // ImageIcon für SchließenLabel erstellen: tabCloseImgIcon = new ImageIcon(getClass().getResource("TabCloseBlack.png")); // SchließenLabel für Tabbeschriftung erzeugen und gestalten: lblClose = new JLabel(tabCloseImgIcon); // Observer für das Image auf das lblClose setzen: tabCloseImgIcon.setImageObserver(lblClose); // MouseListener für Schließenlabel (lblClose) hinzufügen: lblClose.addMouseListener(this); lblIcon = new JLabel(); if (owner.isPrivate()) { lblIcon.setIcon(new ImageIcon(getClass().getResource("private.png"))); } else { lblIcon.setIcon(new ImageIcon(getClass().getResource("gruppe.png"))); } // TitelLabel (lblTitle) + SchließenLabel (btnClose) zum Tab (pnlTab) hinzufügen: this.add(lblIcon); this.add(lblTitle); this.add(lblClose); // den neuen Tab an die Stelle von index setzen: }
public void setImage(String fileName) { this.fileName = fileName; image = Toolkit.getDefaultToolkit().createImage("img\\" + fileName); imageIcon = new ImageIcon(image); imageIcon.setImageObserver(imgLabel); imgLabel.setIcon(imageIcon); imgLabel.setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); }
/** Stop animating this instance of <code>AbstractIconAnimator</code>. */ public void stop() { icon.setImageObserver(null); icon.getImage().flush(); Map map = (Map) contexts.get(context); if (map != null) { map.remove(key); if (map.size() == 0) contexts.remove(context); } }
/** Queue repaint requests for all known painted areas. */ public boolean imageUpdate(Image img, int flags, int x, int y, int width, int height) { if ((flags & (FRAMEBITS | ALLBITS)) != 0) { AnimatedIcon animIcon = (AnimatedIcon) ref.get(); if (animIcon != null) { animIcon.repaint(); } else original.setImageObserver(null); } // Return true if we want to keep painting return (flags & (ALLBITS | ABORT)) == 0; }
public ImagePanel() { setOpaque(false); iconImage = new ImageIcon(bufferedImage); image = Toolkit.getDefaultToolkit().createImage("img\\" + fileName); imageIcon = new ImageIcon(image); imgLabel = new JLabel(iconImage); imageIcon.setImageObserver(imgLabel); imgLabel.setIcon(imageIcon); setLayout(new BorderLayout(0, 0)); setBounds(0, 0, imageIcon.getIconWidth(), imageIcon.getIconHeight()); add(imgLabel); setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); }
public LoadingAnimationHelper() { spinner = new ImageIcon(frame.gui.util.getImageFullname("loading.gif").getImage()); spinner.setImageObserver(this); }