views:

70

answers:

2

I have an OSX cocoa app that is called from my java like so:

   String cmd = "/Users/mike/ASJPictureTaker.app/Contents/MacOS/ASJPictureTaker";

    Runtime run = Runtime.getRuntime();
    Process pr;
    pr = run.exec(cmd);
    pr.waitFor();

The ASJPictureTaker app loads and works fine but when the exec is called it does not take focus from the main app. Is there someway to tell the Cocoa app to steal focus when it is started up? Also, is there away for an application to not allow the user to switch to other applications until it is closed?

A: 

Not allowing the user to switch to other applications is called "kiosk mode" - and it's described here

diciu
Now I am thinking it may be a bad idea to lock the user into "koisk mode" but I am still looking for away to bring Cocoa app to the top of the application stack.
Mike2012
A: 

This call did the trick:

[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];

Mike2012