OK, I've switched to Quentin's method, and it seems to work fine. I
don't mind setting the CLASSPATH, as I'm already using it in a real
Mac app. Here's the code I'm using, in case anyone else wants to try
it.
Bill
try {
Class applicationClass = Class.forName("com.apple.cocoa.application.NSApplication");
if (applicationClass != null) {
// make this application active
java.lang.reflect.Method getShared = applicationClass.getDeclaredMethod("sharedApplication", null);
if (getShared != null) {
Object sharedApp = getShared.invoke(null, null);
Class[] argTypes = { boolean.class };
java.lang.reflect.Method makeActive = applicationClass.getDeclaredMethod("activateIgnoringOtherApps", argTypes);
if (sharedApp != null && makeActive != null) {
Object[] args = new Object[] { new Boolean(true) };
makeActive.invoke(sharedApp, args);
}
}
}
} catch (NoClassDefFoundError e) {
// not on a Mac, or bad classpath
} catch (ClassNotFoundException e) {
// not on a Mac, or bad classpath
} catch (Exception e) {
System.err.println("Exception while attempting to make application active!");
e.printStackTrace(System.err);
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden
This email sent to email@hidden