Currently with swt, I sometimes want a program to arbitrarily come to the foreground (like an alarm clock might).
Typically the following works (jruby):
There is a way to make it work with what you initially tried. You actually need to call shell.setMinimized(false)
and after that shell.setActive()
to restore the previous state of the shell
. However, that only works if the shell
was truely in the minimized state. So here is my final solution, which artificially minimizes the shell
if it was not minimized already. The cost is a quick animation if the minimization has to be done.
shell.getDisplay().syncExec(new Runnable() {
@Override
public void run() {
if (!shell.getMinimized())
{
shell.setMinimized(true);
}
shell.setMinimized(false);
shell.setActive();
}
});