View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2009 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 - ( labelSize.height / 2 ) );
42  		addMouseListener( new MouseAdapter()
43  		{
44  			public void mousePressed( MouseEvent e )
45  			{
46  				if( SoapUISplash.this.frame.isVisible() )
47  				{
48  					setVisible( false );
49  					dispose();
50  				}
51  			}
52  		} );
53  		setVisible( true );
54  	}
55  
56  	@Override
57  	public void setVisible( boolean b )
58  	{
59  		super.setVisible( b );
60  		if( !b )
61  			dispose();
62  	}
63  }