# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: /Users/catlan/Projekte/netbeans/core/swing/plaf/src/org/netbeans/swing/plaf/aqua # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 endcoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: AquaLFCustoms.java *** /Users/catlan/Projekte/netbeans/core/swing/plaf/src/org/netbeans/swing/plaf/aqua/AquaLFCustoms.java Base (1.18) --- /Users/catlan/Projekte/netbeans/core/swing/plaf/src/org/netbeans/swing/plaf/aqua/AquaLFCustoms.java Locally Modified (Based On 1.18) *************** *** 13,18 **** --- 13,19 ---- package org.netbeans.swing.plaf.aqua; + import java.awt.image.BufferedImage; import org.netbeans.swing.plaf.LFCustoms; import org.netbeans.swing.plaf.util.GuaranteedValue; import org.netbeans.swing.plaf.util.UIUtils; *************** *** 21,38 **** import javax.swing.border.Border; import javax.swing.plaf.FontUIResource; import java.awt.*; ! /** Default system-provided customizer for Windows XP LF * Public only to be accessible by ProxyLazyValue, please don't abuse. */ public final class AquaLFCustoms extends LFCustoms { public Object[] createLookAndFeelCustomizationKeysAndValues() { Integer cus = (Integer) UIManager.get("customFontSize"); //NOI18N Object[] result; --- 22,57 ---- import javax.swing.border.Border; import javax.swing.plaf.FontUIResource; import java.awt.*; + import java.io.ByteArrayInputStream; + import java.lang.reflect.Method; + import javax.imageio.ImageIO; + import javax.imageio.ImageReader; + import javax.imageio.stream.ImageInputStream; ! /** Default system-provided customizer for Aqua LF * Public only to be accessible by ProxyLazyValue, please don't abuse. */ public final class AquaLFCustoms extends LFCustoms { public Object[] createLookAndFeelCustomizationKeysAndValues() { + Image applicationIconImage = getApplicationIconImage(); + if (applicationIconImage != null) { + applicationIconImage = applicationIconImage.getScaledInstance(64, 64, Image.SCALE_SMOOTH); + + ImageIcon informationIcon = new ImageIcon(applicationIconImage); + ImageIcon warningIcon = produceIcon( + applicationIconImage, + ((ImageIcon)UIManager.get("OptionPane.warningIcon")).getImage() + ); //NOI18N + + UIManager.put("OptionPane.errorIcon", informationIcon); //NOI18N + UIManager.put("OptionPane.informationIcon", informationIcon); //NOI18N + UIManager.put("OptionPane.questionIcon", informationIcon); //NOI18N + UIManager.put("OptionPane.warningIcon", warningIcon); //NOI18N + } + Integer cus = (Integer) UIManager.get("customFontSize"); //NOI18N Object[] result; if (cus != null) { *************** *** 136,143 **** --- 158,215 ---- return result; } + protected ImageIcon produceIcon(Image appIcon, Image symbolIcon) { + BufferedImage result = new BufferedImage(128, 128, BufferedImage.TYPE_INT_ARGB); + Graphics2D g = result.createGraphics(); + g.drawImage(symbolIcon, 0, 0, null); + g.drawImage(appIcon, 64, 64, null); + g.dispose(); + Image image = (BufferedImage)result; + image = image.getScaledInstance(64, 64, Image.SCALE_SMOOTH); + + return new ImageIcon(image); } + + protected Image getApplicationIconImage() { + try { + //First, lookup the global singleton NSApplication + Class c = Class.forName("com.apple.cocoa.application." + + "NSApplication"); + + Method m = c.getDeclaredMethod("sharedApplication", null); + Object nsapplication = m.invoke(null, null); + + //Now we'll get an NSImage of applicationIconImage + m = nsapplication.getClass().getMethod("applicationIconImage", null); + Object applicationIconImage = m.invoke(nsapplication, null); + + //Now we'll get an NSData as TIFF + m = applicationIconImage.getClass().getMethod("TIFFRepresentation", null); + Object data = m.invoke(applicationIconImage, null); + + //Get the length of the NSData + m = data.getClass().getMethod("length", null); + int dataLength = ((Integer) m.invoke(data, null)).intValue(); + + //Now we'll get an byte array from the NSData + m = data.getClass().getMethod("bytes", new Class[] { int.class, int.class }); + byte[] bytes = (byte[]) m.invoke(data, new Object[] { Integer.valueOf(0), Integer.valueOf(dataLength) }); + + ImageInputStream imageInputStream = + ImageIO.createImageInputStream(new ByteArrayInputStream(bytes)); + + ImageReader imageReader = (ImageReader)ImageIO.getImageReadersByFormatName("tiff").next(); + imageReader.setInput(imageInputStream); + + return (Image)imageReader.read(0); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + }