title: How do you force a java swt program to "move itself to the foreground"?
body: <p>Currently with swt, I sometimes want a program to arbitrarily come to the foreground (like an alarm clock might).</p>
  
  <p>Typically the following works (jruby):</p>
  
  <pre><code>@shell.setMinimized(false)
  @shell.forceActive
  </code></pre>
  
  <p>This brings the shell to the front if it was minimized.</p>
  
  <p>Creating a new shell at any time also brings the (new shell) to the front.</p>
  
  <p>So far so good, however, if the shell is <em>not</em> minimized, the above code just flashes (blinks) the app's icon in the taskbar.  Well actually the first time you run it, it brings it to the front.  After that, it just blinks in the taskbar.  That's windows.  On Linux it appears to only blink in the taskbar (ubuntu default).</p>
  
  <p>Does anybody know of a cross platform way of getting the app to come to the front, in swt?</p>
  
  <p>It seems that no incantation of forceActive setActive setMinimized(false) setFocus forceFocus and setVisible can accomplish this thing.</p>
  
  <p>I'm pretty sure it is possible (at least in windows), as the E Text Editor does it.  Well, that's not swt, but at least some other apps <a href="http://www.generation-nt.com/us/more-single-instance-apps-how-force-its-window-foregroun-help-27562692.html" rel="nofollow noreferrer">have been known to do it</a>.</p>
  
  <p>I'm thinking maybe this is <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=192036" rel="nofollow noreferrer">swt bug 192036</a>?</p>
  
  <p>Many thanks.</p>
  
  <p>Related:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/309023/howto-bring-a-java-window-to-the-front">How to bring a window to the front?</a>  </li>
  <li><a href="http://book.javanb.com/swt-the-standard-widget-toolkit/ch11lev1sec4.html" rel="nofollow noreferrer">Opening a Shell</a></li>
  <li><a href="https://stackoverflow.com/questions/1576463/keep-window-in-foreground-even-if-it-loses-focus">Keep window in foreground (even if it loses focus)</a></li>
  <li><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=244597" rel="nofollow noreferrer">Bug 244597 - Cannot activate shell programatically on gtk</a></li>
  <li><a href="https://stackoverflow.com/questions/204181/need-to-bring-application-to-foreground-on-windows">Need to bring application to foreground on Windows</a></li>
  <li><a href="https://stackoverflow.com/questions/309023/howto-bring-a-java-window-to-the-front">How to bring a window to the front?</a> this swing example might be some type of clue, too...</li>
  </ul>