收录日期:2019/10/18 22:09:52 时间:2009-11-10 23:47:24 标签:java,cocoa,osx,focus

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?

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

This call did the trick:

[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];