Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: jmmv/progs/DiskCat/SplashWindow.java


1   /*
2    * DiskCat - Disk Cataloguer
3    * Copyright (C) 2002 Julio Merino <slink@unixbsd.org>
4    *
5    * This program is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU General Public License as
7    * published by the Free Software Foundation; either version 2 of the
8    * License, or (at your option) any later version.
9   
10   * This program is distributed in the hope that it will be useful, but
11   * WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   * General Public License for more details.
14  
15   * You should have received a copy of the GNU General Public License
16   * along with this program; if not, write to the Free Software
17   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18   * USA
19   */
20  
21  package jmmv.progs.DiskCat;
22  
23  import java.awt.BorderLayout;
24  import java.awt.Color;
25  import java.awt.Dimension;
26  import java.awt.Image;
27  import java.awt.Toolkit;
28  import java.net.URL;
29  import javax.swing.ImageIcon;
30  import javax.swing.JLabel;
31  import javax.swing.JWindow;
32  
33  class SplashWindow extends JWindow {
34      SplashWindow() {
35    ImageIcon splashIcon = getImageResource("splash.jpg");
36          Image image = splashIcon.getImage();
37    Dimension size = new Dimension(image.getWidth(null), image.getHeight(null));
38    this.setSize(size);
39    
40          Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
41          setLocation((screenSize.width-size.width)/2,
42          (screenSize.height-size.height)/2);
43    JLabel splashLabel = new JLabel(splashIcon);
44    //  splashLabel.setBorder(BorderFactory.createLineBorder(Color.black,1));
45    
46    this.getContentPane().add(splashLabel, BorderLayout.CENTER);
47    this.pack();
48          this.setVisible(true);
49      }
50  
51      final ImageIcon getImageResource(final String imageName) {  
52    ClassLoader cl = null;
53    URL imageURL = null;
54    
55    if (cl ==  null) {
56        imageURL = ClassLoader.getSystemResource(imageName);
57        return new ImageIcon(imageURL);
58    }    
59    
60    imageURL = cl.getResource(imageName);
61    if (imageURL == null) {
62        imageURL = ClassLoader.getSystemResource(imageName);
63    }
64    return new ImageIcon(imageURL);
65      }
66  }