How do you force a java swt program to “move itself to the foreground”?

后端 未结 6 417
逝去的感伤
逝去的感伤 2020-12-15 22:20

Currently with swt, I sometimes want a program to arbitrarily come to the foreground (like an alarm clock might).

Typically the following works (jruby):



        
6条回答
  •  眼角桃花
    2020-12-15 22:50

    This worked for me on Windows 7 and Ubuntu:

    private void bringToFront(final Shell shell) {
        shell.getDisplay().asyncExec(new Runnable() {
            public void run() {
                shell.forceActive();
            }
        });
    }
    

提交回复
热议问题