From: jprocter Date: Wed, 1 Aug 2012 15:21:52 +0000 (+0100) Subject: JAL-1130 made SplashScreen able to be a dialog that supports opening of hyperlinks... X-Git-Tag: Jalview_2_9~307^2~10 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=3a124a6618aca04d87fa89a76d79cc03c4d45e47;p=jalview.git JAL-1130 made SplashScreen able to be a dialog that supports opening of hyperlinks embedded in text --- diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 3c34deb..d6ab3ae 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -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) diff --git a/src/jalview/gui/SplashScreen.java b/src/jalview/gui/SplashScreen.java index b0be269..97a2a24 100755 --- a/src/jalview/gui/SplashScreen.java +++ b/src/jalview/gui/SplashScreen.java @@ -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