private void updateLabelSizes() { Dictionary labelTable = getLabelTable(); if (labelTable != null) { Enumeration labels = labelTable.elements(); while (labels.hasMoreElements()) { JComponent component = (JComponent) labels.nextElement(); component.setSize(component.getPreferredSize()); } } }
/** * {@inheritDoc} * * @since 1.7 */ public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h) { if (!isShowing()) { return false; } // Check that there is a label with such image Enumeration elements = labelTable.elements(); while (elements.hasMoreElements()) { Component component = (Component) elements.nextElement(); if (component instanceof JLabel) { JLabel label = (JLabel) component; if (SwingUtilities.doesIconReferenceImage(label.getIcon(), img) || SwingUtilities.doesIconReferenceImage(label.getDisabledIcon(), img)) { return super.imageUpdate(img, infoflags, x, y, w, h); } } } return false; }