| Home >> All >> com >> cybertivity >> powerjournal >> [ framework Javadoc ] |
Source code: com/cybertivity/powerjournal/framework/Splash.java
1 /* 2 * Title: Similated Intelligence 3 * Copyright: Copyright (c) 2001 Cybertivity 4 * Company: <A HREF="http://www.cybertivity.com">Cybertivity</A> 5 * @author <A HREF="mailto:chris.arrowood@cybertivity.com">Chris Arrowood</A> 6 * @version $Id: Splash.java,v 1.1.1.1 2001/11/24 03:51:34 arrowood Exp $ 7 */ 8 package com.cybertivity.powerjournal.framework; 9 10 11 import java.awt.BorderLayout; 12 import java.awt.Color; 13 import java.awt.Dimension; 14 import java.awt.MediaTracker; 15 import java.awt.Toolkit; 16 import javax.swing.BorderFactory; 17 import javax.swing.ImageIcon; 18 import javax.swing.JLabel; 19 import javax.swing.JPanel; 20 import javax.swing.JWindow; 21 22 class Splash extends JWindow { 23 /** 24 * Constructor for the Splash object 25 * 26 * @param filePath Description of Parameter 27 */ 28 public Splash(String filePath) { 29 getContentPane().add(new SplashPanel(filePath), BorderLayout.CENTER); 30 pack(); 31 32 Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); 33 int height = getHeight(); 34 int width = getWidth(); 35 36 setLocation((screen.width - width) / 2, (screen.height - height) / 2); 37 setVisible(true); 38 } 39 40 41 private class SplashPanel extends JPanel { 42 /** 43 * Constructor for the SplashPanel object 44 * 45 * @param filePath Description of Parameter 46 */ 47 public SplashPanel(String filePath) { 48 this.setBorder(BorderFactory.createLineBorder(Color.black)); 49 this.setLayout(new BorderLayout()); 50 51 ImageIcon i = 52 new ImageIcon(this.getClass().getResource(filePath)); 53 JLabel label = new JLabel(i); 54 this.add(label, BorderLayout.CENTER); 55 56 MediaTracker tracker = new MediaTracker(label); 57 tracker.addImage(i.getImage(), 0); 58 59 try { 60 tracker.waitForAll(); 61 } catch(InterruptedException ex) { 62 // Do nothing 63 } 64 } 65 } 66 }