Search in sources :

Example 1 with ImageIconUIResource

use of sun.swing.ImageIconUIResource in project jdk8u_jdk by JetBrains.

the class NimbusLookAndFeel method getDisabledIcon.

@Override
public Icon getDisabledIcon(JComponent component, Icon icon) {
    if (icon instanceof SynthIcon) {
        SynthIcon si = (SynthIcon) icon;
        BufferedImage img = EffectUtils.createCompatibleTranslucentImage(si.getIconWidth(), si.getIconHeight());
        Graphics2D gfx = img.createGraphics();
        si.paintIcon(component, gfx, 0, 0);
        gfx.dispose();
        return new ImageIconUIResource(GrayFilter.createDisabledImage(img));
    } else {
        return super.getDisabledIcon(component, icon);
    }
}
Also used : ImageIconUIResource(sun.swing.ImageIconUIResource) BufferedImage(java.awt.image.BufferedImage) SynthIcon(sun.swing.plaf.synth.SynthIcon) Graphics2D(java.awt.Graphics2D)

Example 2 with ImageIconUIResource

use of sun.swing.ImageIconUIResource in project jdk8u_jdk by JetBrains.

the class WindowsLookAndFeel method getDisabledIcon.

/**
     * {@inheritDoc}
     *
     * @since 1.6
     */
public Icon getDisabledIcon(JComponent component, Icon icon) {
    // in particular by the WindowsFileChooserUI class)
    if (icon != null && component != null && Boolean.TRUE.equals(component.getClientProperty(HI_RES_DISABLED_ICON_CLIENT_KEY)) && icon.getIconWidth() > 0 && icon.getIconHeight() > 0) {
        BufferedImage img = new BufferedImage(icon.getIconWidth(), icon.getIconWidth(), BufferedImage.TYPE_INT_ARGB);
        icon.paintIcon(component, img.getGraphics(), 0, 0);
        ImageFilter filter = new RGBGrayFilter();
        ImageProducer producer = new FilteredImageSource(img.getSource(), filter);
        Image resultImage = component.createImage(producer);
        return new ImageIconUIResource(resultImage);
    }
    return super.getDisabledIcon(component, icon);
}
Also used : RGBImageFilter(java.awt.image.RGBImageFilter) ImageFilter(java.awt.image.ImageFilter) ImageIconUIResource(sun.swing.ImageIconUIResource) ImageProducer(java.awt.image.ImageProducer) FilteredImageSource(java.awt.image.FilteredImageSource) BufferedImage(java.awt.image.BufferedImage) BufferedImage(java.awt.image.BufferedImage)

Aggregations

BufferedImage (java.awt.image.BufferedImage)2 ImageIconUIResource (sun.swing.ImageIconUIResource)2 Graphics2D (java.awt.Graphics2D)1 FilteredImageSource (java.awt.image.FilteredImageSource)1 ImageFilter (java.awt.image.ImageFilter)1 ImageProducer (java.awt.image.ImageProducer)1 RGBImageFilter (java.awt.image.RGBImageFilter)1 SynthIcon (sun.swing.plaf.synth.SynthIcon)1