JAL-1130 made SplashScreen able to be a dialog that supports opening of hyperlinks...
authorjprocter <jprocter@compbio.dundee.ac.uk>
Wed, 1 Aug 2012 15:21:52 +0000 (16:21 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Wed, 19 Sep 2012 12:17:30 +0000 (13:17 +0100)
src/jalview/gui/Desktop.java
src/jalview/gui/SplashScreen.java

index 3c34deb..d6ab3ae 100644 (file)
@@ -1062,10 +1062,11 @@ public class Desktop extends jalview.jbgui.GDesktop implements
    */
   public void aboutMenuItem_actionPerformed(ActionEvent e)
   {
-    StringBuffer message = getAboutMessage(false);
-    JOptionPane.showInternalMessageDialog(Desktop.desktop,
-
-    message.toString(), "About Jalview", JOptionPane.INFORMATION_MESSAGE);
+//    StringBuffer message = getAboutMessage(false);
+//    JOptionPane.showInternalMessageDialog(Desktop.desktop,
+//
+//    message.toString(), "About Jalview", JOptionPane.INFORMATION_MESSAGE);
+    new Thread(new Runnable() { public void run() {new SplashScreen(true);}}).start();
   }
 
   public StringBuffer getAboutMessage(boolean shortv)
index b0be269..97a2a24 100755 (executable)
@@ -21,6 +21,8 @@ import java.awt.*;
 import java.awt.event.*;
 
 import javax.swing.*;
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkListener;
 
 /**
  * DOCUMENT ME!
@@ -28,7 +30,7 @@ import javax.swing.*;
  * @author $author$
  * @version $Revision$
  */
-public class SplashScreen extends JPanel implements Runnable
+public class SplashScreen extends JPanel implements Runnable, HyperlinkListener
 {
   boolean visible = true;
 
@@ -49,18 +51,33 @@ public class SplashScreen extends JPanel implements Runnable
    */
   public SplashScreen()
   {
+    this(false);
+  }
+  private boolean interactiveDialog=false;
+  /**
+   * 
+   * @param interactive if true - an internal dialog is opened rather than a free-floating splash screen
+   */
+  public SplashScreen(boolean interactive)
+  {
+    this.interactiveDialog=interactive;
+    // show a splashscreen that will disapper
     Thread t = new Thread(this);
     t.start();
   }
 
+
   MouseAdapter closer = new MouseAdapter()
   {
     public void mousePressed(MouseEvent evt)
     {
       try
       {
-        visible = false;
-        closeSplash();
+        if (!interactiveDialog)
+        {
+          visible = false;
+          closeSplash();
+        }
       } catch (Exception ex)
       {
       }
@@ -93,7 +110,7 @@ public class SplashScreen extends JPanel implements Runnable
 
     iframe = new JInternalFrame();
     iframe.setFrameIcon(null);
-    iframe.setClosable(false);
+    iframe.setClosable(interactiveDialog);
     this.setLayout(new BorderLayout());
     iframe.setContentPane(this);
     iframe.setLayer(JLayeredPane.PALETTE_LAYER);
@@ -124,16 +141,17 @@ public class SplashScreen extends JPanel implements Runnable
       authlist=new JTextPane();
       authlist.setEditable(false);
       authlist.addMouseListener(closer);
+      authlist.addHyperlinkListener(this);
       authlist.setContentType("text/html");
       authlist.setText(newtext);
       authlist.setVisible(true);
       add(authlist, BorderLayout.CENTER);
-      iframe.pack();
-      iframe.setVisible(true);
       iframe.setBounds((int) ((Desktop.instance.getWidth() - 750) / 2),
               (int) ((Desktop.instance.getHeight() - 160) / 2), 750,
               iframe.getPreferredSize().height);
       //System.err.println("New preferred size: "+iframe.getPreferredSize().height);
+      iframe.validate();
+      iframe.setVisible(true);
 
       return true;
     }
@@ -151,21 +169,30 @@ public class SplashScreen extends JPanel implements Runnable
 
     while (visible)
     {
+      iframe.repaint();
       try
       {
         Thread.sleep(500);
       } catch (Exception ex)
       {
       }
-
-      if (((System.currentTimeMillis() / 1000) - startTime) > 5)
+      
+      if (!interactiveDialog && ((System.currentTimeMillis() / 1000) - startTime) > 5)
       {
         visible = false;
       }
 
       if (visible && refreshText())
       {
-          repaint();
+//          if (interactiveDialog) {
+            iframe.repaint();
+//          } else {
+//            iframe.repaint();
+//          };
+      }
+      if (interactiveDialog)
+      {
+        return;
       }
     }
 
@@ -251,4 +278,10 @@ public class SplashScreen extends JPanel implements Runnable
      * += fontSize + 4); }
      */
   }
+  @Override
+  public void hyperlinkUpdate(HyperlinkEvent e)
+  {
+    Desktop.hyperlinkUpdate(e);
+    
+  }
 }
\ No newline at end of file