Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Making an application "active" from java



Ha! I spent yesterday struggling with bringing my application to the foreground, and joined this list yesterday evening; it's a wonderful coincidence to find that topic being discussed!

I had come up with Mary's solution, but I was using the following applescript

   "tell application \"MyApp\" to activate"

which works as long as you've built your code into a full application bundle.

My app does bits of AppleScript quite regularly and it isn't always very snappy to have to fire up a new osascript process every time. But the NSAppleScript classes do seem to be broken unless you're running in a full Cocoa-Java app, so osascript appears to be the only way.

However, for this particular problem, Bill's earlier post led me to:

	NSApplication app = NSApplication.sharedApplication();
	app.activateIgnoringOtherApps(true);

which seems to work for me.

Quentin
----
Dr Quentin Stafford-Fraser
http://www.qandr.org/quentin



I could make the suggested solution work by executing the script

"tell application \"Finder\" to set frontmost of application process \"JavaApplicationStub\" to true"

but not using my application name.


_______________________________________________ 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
References: 
 >Re: Making an application "active" from java (From: Greg Guerin <email@hidden>)
 >Re: Making an application "active" from java (From: Michael Kölling <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.