From 8ada852308f2823efb12af7795e21eb3ff08f598 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Tue, 14 Jul 2009 23:37:04 +0200 Subject: Used reflection to call Apple native look to avoid errors in a non-mac development environment --- src/lombok/installer/AppleNativeLook.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/lombok/installer/AppleNativeLook.java b/src/lombok/installer/AppleNativeLook.java index 1d3cfff7..b2c90555 100644 --- a/src/lombok/installer/AppleNativeLook.java +++ b/src/lombok/installer/AppleNativeLook.java @@ -21,21 +21,23 @@ */ package lombok.installer; -import java.io.IOException; +import java.awt.Image; +import java.awt.image.BufferedImage; import javax.imageio.ImageIO; -import com.apple.eawt.Application; - /** * Mac OS X specific code to gussy up the GUI a little bit, mostly with a nice dock icon. Well, nicer than * the standard icon, at any rate. */ class AppleNativeLook { - public static void go() throws IOException { - Application app = Application.getApplication(); - app.removeAboutMenuItem(); - app.removePreferencesMenuItem(); - app.setDockIconImage(ImageIO.read(AppleNativeLook.class.getResource("lombokIcon.png"))); + public static void go() throws Exception { + Class appClass = Class.forName("com.apple.eawt.Application"); + Object app = appClass.getMethod("getApplication").invoke(null); + appClass.getMethod("removeAboutMenuItem").invoke(app); + appClass.getMethod("removePreferencesMenuItem").invoke(app); + + BufferedImage image = ImageIO.read(AppleNativeLook.class.getResource("lombokIcon.png")); + appClass.getMethod("setDockIconImage", Image.class).invoke(app, image); } } -- cgit