View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2007 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of version 2.1 of the GNU Lesser General Public License as published by 
6    *  the Free Software Foundation.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
10   *  See the GNU Lesser General Public License for more details at gnu.org.
11   */
12   
13  package com.eviware.soapui;
14  
15  import java.awt.BorderLayout;
16  import java.awt.Dimension;
17  import java.awt.Toolkit;
18  import java.awt.event.MouseAdapter;
19  import java.awt.event.MouseEvent;
20  
21  import javax.swing.ImageIcon;
22  import javax.swing.JFrame;
23  import javax.swing.JLabel;
24  import javax.swing.JWindow;
25  
26  import com.eviware.soapui.support.UISupport;
27  
28  public class SoapUISplash extends JWindow
29  	{
30  		private final JFrame frame;
31  
32  		public SoapUISplash( String fileName, JFrame frame )
33  		{
34  			super( frame );
35  			this.frame = frame;
36  			JLabel l = new JLabel( new ImageIcon( UISupport.findSplash( fileName ) ) );
37  			getContentPane().add( l, BorderLayout.CENTER );
38  			pack();
39  			Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
40  			Dimension labelSize = l.getPreferredSize();
41  			setLocation( screenSize.width / 2 - ( labelSize.width / 2 ), screenSize.height / 2
42  						- ( labelSize.height / 2 ) );
43  			addMouseListener( new MouseAdapter()
44  			{
45  				public void mousePressed( MouseEvent e )
46  				{
47  					if( SoapUISplash.this.frame.isVisible())
48  					{
49  						setVisible( false );
50  						dispose();
51  					}
52  				}
53  			} );
54  			setVisible( true );
55  		}
56  
57  		@Override
58  		public void setVisible( boolean b )
59  		{
60  			super.setVisible( b );
61  			if( !b )
62  				dispose();
63  		}
64  	}