From 495723ac6f2a30ba8d7f5e65b0723e2ba8f121e1 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Fri, 4 May 2007 10:32:03 +0000 Subject: [PATCH] Splash screen is not added using normal method, prevents null paint bug --- src/jalview/gui/Desktop.java | 41 +++++++------------------------------ src/jalview/gui/SplashScreen.java | 35 ++++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 37 deletions(-) diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 0310f2a..263eb18 100755 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -65,31 +65,11 @@ public class Desktop instance = this; doVamsasClientCheck(); doGroovyCheck(); - Image image = null; - try - { - java.net.URL url = getClass().getResource("/images/logo.gif"); - - if (url != null) - { - image = java.awt.Toolkit.getDefaultToolkit().createImage(url); - - MediaTracker mt = new MediaTracker(this); - mt.addImage(image, 0); - mt.waitForID(0); - setIconImage(image); - } - } - catch (Exception ex) - { - } - setTitle("Jalview " + jalview.bin.Cache.getProperty("VERSION")); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - // desktop = new MyDesktopPane(true); desktop = new JDesktopPane(); desktop.setBackground(Color.white); getContentPane().setLayout(new BorderLayout()); @@ -141,15 +121,8 @@ public class Desktop /////////Add a splashscreen on startup /////////Add a splashscreen on startup - JInternalFrame frame = new JInternalFrame(); - - SplashScreen splash = new SplashScreen(frame, image); - frame.setContentPane(splash); - frame.setLayer(JLayeredPane.PALETTE_LAYER); - frame.setLocation( (int) ( (getWidth() - 750) / 2), - (int) ( (getHeight() - 160) / 2)); + new SplashScreen(); - addInternalFrame(frame, "", 750, 160, false); discoverer = new jalview.ws.Discoverer(); // Only gets started if gui is displayed. } @@ -1112,23 +1085,23 @@ public class Desktop { groovyShell = new JMenuItem(); groovyShell.setText("Groovy Shell..."); - groovyShell.addActionListener(new ActionListener() + groovyShell.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groovyShell_actionPerformed(e); - } + } }); toolsMenu.add(groovyShell); groovyShell.setVisible(true); } } - /** + /** * Accessor method to quickly get all the AlignmentFrames - * loaded. - */ + * loaded. + */ protected AlignFrame[] getAlignframes() { JInternalFrame[] frames = Desktop.desktop.getAllFrames(); - + if (frames == null) { return null; diff --git a/src/jalview/gui/SplashScreen.java b/src/jalview/gui/SplashScreen.java index a033ec7..8b92644 100755 --- a/src/jalview/gui/SplashScreen.java +++ b/src/jalview/gui/SplashScreen.java @@ -43,10 +43,25 @@ public class SplashScreen * @param iframe DOCUMENT ME! * @param i DOCUMENT ME! */ - public SplashScreen(JInternalFrame iframe, Image i) + public SplashScreen() { - this.iframe = iframe; - image = i; + try + { + java.net.URL url = getClass().getResource("/images/logo.gif"); + + if (url != null) + { + image = java.awt.Toolkit.getDefaultToolkit().createImage(url); + + MediaTracker mt = new MediaTracker(this); + mt.addImage(image, 0); + mt.waitForID(0); + Desktop.instance.setIconImage(image); + } + } + catch (Exception ex) + { + } Thread t = new Thread(this); t.start(); @@ -63,6 +78,19 @@ public class SplashScreen } } }); + + iframe = new JInternalFrame(); + iframe.setFrameIcon(null); + iframe.setClosable(false); + iframe.setContentPane(this); + iframe.setLayer(JLayeredPane.PALETTE_LAYER); + + Desktop.desktop.add(iframe); + + iframe.setVisible(true); + iframe.setBounds( (int) ( (Desktop.instance.getWidth() - 750) / 2), + (int) ( (Desktop.instance.getHeight() - 160) / 2), + 750, 160); } /** @@ -99,6 +127,7 @@ public class SplashScreen { try { + iframe.setClosed(true); } catch (Exception ex) -- 1.7.10.2