From: Jim Procter Date: Tue, 10 Jul 2018 16:44:40 +0000 (+0100) Subject: JAL-3026 j2sNative fix for About.. panel/splashscreen : use JLabel rather than JTextP... X-Git-Tag: Release_2_11_4_0~45^2~18^2~552 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=bd53adc27eab07569b1944a7c33f31c41dad785f;p=jalview.git JAL-3026 j2sNative fix for About.. panel/splashscreen : use JLabel rather than JTextPane and use tag rather than mediaTracker to display jalview logo in about pane. --- diff --git a/src/jalview/gui/SplashScreen.java b/src/jalview/gui/SplashScreen.java index 22b697e..a122eb6 100755 --- a/src/jalview/gui/SplashScreen.java +++ b/src/jalview/gui/SplashScreen.java @@ -22,6 +22,7 @@ package jalview.gui; import java.awt.BorderLayout; import java.awt.Color; +import java.awt.Component; import java.awt.Dimension; import java.awt.Font; import java.awt.Graphics; @@ -31,8 +32,10 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.JInternalFrame; +import javax.swing.JLabel; import javax.swing.JLayeredPane; import javax.swing.JPanel; +import javax.swing.JTextField; import javax.swing.JTextPane; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; @@ -50,7 +53,10 @@ public class SplashScreen extends JPanel JPanel iconimg = new JPanel(new BorderLayout()); - JTextPane authlist = new JTextPane(); + /** + * either text area in javascript or in java text pane + */ + Component authlist; JInternalFrame iframe; @@ -80,8 +86,23 @@ public class SplashScreen extends JPanel { this.interactiveDialog = interactive; // show a splashscreen that will disapper - Thread t = new Thread(this); - t.start(); + if (/** @j2sNative true || */ false) + { + authlist = new JLabel(""); + run(); + } + else + { + /** + * @j2sNative + */ + { + authlist = new JTextPane(); + Thread t = new Thread(this); + t.start(); + } + } + } MouseAdapter closer = new MouseAdapter() @@ -114,7 +135,7 @@ public class SplashScreen extends JPanel java.net.URL urllogo = getClass() .getResource("/images/Jalview_Logo_small.png"); - if (url != null) + if (/** @j2sNative false || */ url != null) { image = java.awt.Toolkit.getDefaultToolkit().createImage(url); Image logo = java.awt.Toolkit.getDefaultToolkit() @@ -148,12 +169,18 @@ public class SplashScreen extends JPanel this.setLayout(new BorderLayout()); iframe.setContentPane(this); iframe.setLayer(JLayeredPane.PALETTE_LAYER); + /** + * we add image directly in html for javascript ? + * @j2sNative + */ + { + ((JTextPane) authlist).setEditable(false); - SplashImage splashimg = new SplashImage(image); - iconimg.add(splashimg, BorderLayout.CENTER); - add(iconimg, BorderLayout.NORTH); + SplashImage splashimg = new SplashImage(image); + iconimg.add(splashimg, BorderLayout.CENTER); + add(iconimg, BorderLayout.NORTH); + } add(authlist, BorderLayout.CENTER); - authlist.setEditable(false); authlist.addMouseListener(closer); Desktop.desktop.add(iframe); refreshText(); @@ -164,6 +191,7 @@ public class SplashScreen extends JPanel /** * update text in author text panel reflecting current version information */ + @SuppressWarnings("unused") protected boolean refreshText() { String newtext = Desktop.instance.getAboutMessage(true).toString(); @@ -172,12 +200,25 @@ public class SplashScreen extends JPanel { iframe.setVisible(false); oldtext = newtext.length(); - authlist = new JTextPane(); - authlist.setEditable(false); + if (/** @j2sNative true || */ false) + { + authlist = new JLabel("


"+newtext); + ((JLabel) authlist).setOpaque(true); + ((JLabel) authlist).setBackground(Color.white); + } else { + /** + * @j2sNative + */ + { + authlist = new JTextPane(); + ((JTextPane) authlist).setEditable(false); + ((JTextPane) authlist).setContentType("text/html"); + ((JTextPane) authlist).setText(newtext); + ((JTextPane) authlist).addHyperlinkListener(this); + } + } authlist.addMouseListener(closer); - authlist.addHyperlinkListener(this); - authlist.setContentType("text/html"); - authlist.setText(newtext); + authlist.setVisible(true); authlist.setSize(new Dimension(750, 375)); add(authlist, BorderLayout.CENTER); @@ -187,7 +228,6 @@ public class SplashScreen extends JPanel authlist.getHeight() + iconimg.getHeight()); iframe.validate(); iframe.setVisible(true); - return true; } return false; @@ -257,8 +297,10 @@ public class SplashScreen extends JPanel public SplashImage(Image todisplay) { image = todisplay; - setPreferredSize(new Dimension(image.getWidth(this) + 8, + if (image!=null) + { setPreferredSize(new Dimension(image.getWidth(this) + 8, image.getHeight(this))); + } } @Override