X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FDesktop.java;h=5dadeb3f5721b4ef87c000c958e8d83ffe29d7d4;hb=6fa0f79908a356c2efa73d5518544daea904ae89;hp=a5778a74b422e356204378becd75308db1c9f858;hpb=3be300f0d9107885e183ae7c86b081c8e6c6780f;p=jalview.git diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index a5778a7..5dadeb3 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -43,6 +43,8 @@ import javax.swing.*; import javax.swing.event.MenuEvent; import javax.swing.event.MenuListener; +import com.sun.xml.internal.ws.streaming.TidyXMLStreamReader; + /** * Jalview Desktop * @@ -302,7 +304,24 @@ public class Desktop extends jalview.jbgui.GDesktop implements } } }); - + this.addFocusListener(new FocusListener() + { + + @Override + public void focusLost(FocusEvent e) + { + // TODO Auto-generated method stub + + } + + @Override + public void focusGained(FocusEvent e) + { + Cache.log.debug("Relaying windows after focus gain"); + // make sure that we sort windows properly after we gain focus + instance.relayerWindows(); + } + }); this.setDropTarget(new java.awt.dnd.DropTarget(desktop, this)); // Spawn a thread that shows the splashscreen SwingUtilities.invokeLater(new Runnable() @@ -349,14 +368,27 @@ public class Desktop extends jalview.jbgui.GDesktop implements { showNews(showNews.isSelected()); } - void showNews(boolean default1) + void showNews(boolean visible) { { - jvnews.setVisible(default1); - if (default1) + jvnews.setVisible(visible); + showNews.setSelected(visible); + if (visible) { jvnews.refreshNews(); jvnews.toFront(); + // try real hard to get focus when the news is first opened + new Thread(new Runnable() { + @Override + public void run() + { + while (jvnews.isVisible() && !jvnews.requestFocusInWindow()) + { + try { Thread.sleep(50); } catch (InterruptedException x) {}; + } + + } + }).start(); } } } @@ -1985,6 +2017,17 @@ public class Desktop extends jalview.jbgui.GDesktop implements } + /** + * fixes stacking order after a modal dialog to ensure windows that should be on top actually are + */ + public void relayerWindows() + { + if (jvnews!=null && jvnews.isVisible()) + { + jvnews.toFront(); + } + } + protected JMenuItem groovyShell; public void doGroovyCheck()