4

I have simple java application

main(){
Robot robot = new Robot();
Thread.sleep(5000);
}

It grabs focus from my other java application when i run it on macosx. Can i prevent it? It is also possible to paste Toolkit.getDefaultTookit instead of Robot with same effect.

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Andrei N
  • 4,716
  • 4
  • 29
  • 29

1 Answers1

2

You should set property apple.awt.UIElement equals true by "java -Dapple.awt.UIElement=true" or by System.setProperty()

Andrei N
  • 4,716
  • 4
  • 29
  • 29
  • 2
    From [Apple's docs](https://developer.apple.com/library/mac/documentation/java/Reference/Java_PropertiesRef/Articles/JavaSystemProperties.html); UIElement "Suppresses the normal application Dock icon and menu bar from appearing. Only appropriate for background applications which show a tray icon or other alternate user interface for accessing the apps windows. Unlike `java.awt.headless=true`, this does not suppress windows and dialogs from actually appearing on screen. The default value is false." – Toby Feb 20 '14 at 18:09