001    /*
002            Copyright (C) 2003 Adam Olsen
003    
004            This program is free software; you can redistribute it and/or modify
005            it under the terms of the GNU General Public License as published by
006            the Free Software Foundation; either version 1, or (at your option)
007            any later version.
008    
009            This program is distributed in the hope that it will be useful,
010            but WITHOUT ANY WARRANTY; without even the implied warranty of
011            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012            GNU General Public License for more details.
013    
014            You should have received a copy of the GNU General Public License
015            along with this program; if not, write to the Free Software
016            Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
017    */
018    
019    package com.valhalla.jbother;
020    
021    import java.awt.event.ActionEvent;
022    import java.awt.event.ActionListener;
023    
024    import javax.swing.*;
025    
026    import com.valhalla.gui.*;
027    import com.valhalla.jbother.*;
028    
029    /**
030     * Displays a splash screen for a second
031     * @author Adam Olsen
032     * @version 1.0
033    **/
034    public class SplashScreen extends JWindow
035    {
036            javax.swing.Timer splashTimer = new javax.swing.Timer( 1500, new SplashHandler() );
037    
038            /**
039             * Default constructor
040            **/
041            public SplashScreen()
042            {
043                    super( BuddyList.getInstance() );
044    
045                    ImageIcon splashImage = Standard.getIcon( "images/splashimage.png" );
046                    getContentPane().add( new JLabel( splashImage ) );
047                    pack();
048    
049                    setLocationRelativeTo( null );
050                    show();
051                    splashTimer.start();
052            }
053    
054            /**
055             * Closes the SplashScreen
056             * Closes the SplashScreen after the time has expired
057             * @author Adam Olsen
058             * @version 1.0
059            **/
060            class SplashHandler implements ActionListener
061            {
062                    /**
063                     * Called by the <code>javax.swing.Timer</code>
064                    **/
065                    public void actionPerformed( ActionEvent e )
066                    {
067                            SwingUtilities.invokeLater( new Runnable()
068                            {
069                                    public void run()
070                                    {
071                                            splashTimer.stop();
072                                            hide();
073                                            com.valhalla.jbother.JBotherLoader.launch();
074                                            dispose();
075                                    }
076                            } );
077                    }
078            }
079    }