Mega Code Archive

 
Categories / Java / Swing JFC
 

JSplash extends JWindow

/*  * Copyright (C) 2004 Giuseppe MANNA  *   * This file is part of FreeReportBuilder  *   * FreeReportBuilder is free software; you can redistribute it and/or  * modify it under the terms of the GNU General Public License  * as published by the Free Software Foundation; either version 2  * of the License, or (at your option) any later version.  *   * This program is distributed in the hope that it will be useful,  * but WITHOUT ANY WARRANTY; without even the implied warranty of  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  * GNU General Public License for more details.  *   * You should have received a copy of the GNU General Public License  * along with this program; if not, write to the Free Software  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.  *   */ import java.awt.*; import javax.swing.border.*; import javax.swing.*; public final class JSplash extends JWindow {    private JLabel lblVersion = new JLabel();    public JSplash()    {       init();       center();    }    private void init()    {       JPanel    pnlImage   = new JPanel();       ImageIcon image   = new ImageIcon( getClass().getResource( "img/logo.jpg" ) );       JLabel    lblBack = new JLabel( image );       Border    raisedbevel  = BorderFactory.createRaisedBevelBorder();       Border    loweredbevel = BorderFactory.createLoweredBevelBorder();       lblBack.setBounds( 0, 0, image.getIconWidth(), image.getIconHeight() );       getLayeredPane().add( lblBack, new Integer( Integer.MIN_VALUE ) );       pnlImage.setLayout( null );       pnlImage.setOpaque( false );       pnlImage.setBorder( BorderFactory.createCompoundBorder( raisedbevel, loweredbevel ) );       pnlImage.add( this.lblVersion );       this.lblVersion.setForeground( Color.white );       this.lblVersion.setFont( new Font( "Dialog", Font.PLAIN, 12 ) );       this.lblVersion.setBounds( 15, 69, 120, 20 );       setContentPane( pnlImage );       setSize( image.getIconWidth(), image.getIconHeight() );    }        private void center()    {       Dimension scr = Toolkit.getDefaultToolkit().getScreenSize();       int       nX  = (int) (scr.getWidth()  - getWidth()  ) / 2;       int       nY  = (int) (scr.getHeight() - getHeight() ) / 2;       setLocation( nX, nY );    } }