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



I used to use:

		ProcessSerialNumberStruct psnStruct = new ProcessSerialNumberStruct();
		ProcessFunctions.GetCurrentProcess(psnStruct);
		ProcessFunctions.SetFrontProcess(psnStruct);

but now I use:

String [] args = { "osascript",
"-e",
"tell application \"Finder\" to set frontmost of application process \"MyApp\" to true"};
try{
Runtime.getRuntime().exec (args );
}
catch(Exception e){
e.printStackTrace();
}


Both are OS X only - and we're still with Java1.3.1 - but effective!

mwaller

On Monday, December 13, 2004, at 10:45 pm, email@hidden wrote:

Yes, I think a Mac OS X solution is what I need for now (though it
would be nice if the Java SDK had something like this).

I see that somewhere there's a class called
"com.apple.cocoa.application.NSApplication", which has a method
"activateIgnoringOtherApps", which sounds like exactly what I want.

http://developer.apple.com/documentation/Cocoa/Reference/ ApplicationKit/Java/Classes/NSApplication.html#//apple_ref/doc/uid/ 20000624/CACCJDJC

But I can't find a jar file on my system that includes this class.  Is
this old documentation?  Is this class obsolete?

Bill

Bill Janssen wrote:
| Is there some way,
| from Java, to make my application the "active" application?

If your application will run only on OS X, you could exec() the "open" command. (That would require your application knowing it's own name and location, however.)

Mary Waller
MPC Data Ltd
+44 (0) 1225 861311

_______________________________________________
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


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.