1 33 34 package edu.rice.cs.drjava.ui; 35 36 import javax.swing.*; 37 import java.awt.*; 38 import java.awt.event.*; 39 40 44 public class SplashScreen extends JWindow { 45 private static final String SPLASH_ICON = "splash.png"; 46 private static final int PAUSE_TIME = 4000; 48 private ImageIcon _icon; 49 50 53 public SplashScreen() { 54 _icon = MainFrame.getIcon(SPLASH_ICON); 55 getContentPane().add(new JLabel(_icon, SwingConstants.CENTER)); 56 setSize(_icon.getIconWidth(), _icon.getIconHeight()); 57 GraphicsDevice[] dev = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); 60 Rectangle rec = dev[0].getDefaultConfiguration().getBounds(); 61 Point ownerLoc = rec.getLocation(); 62 Dimension ownerSize = rec.getSize(); 63 Dimension frameSize = getSize(); 64 setLocation(ownerLoc.x + (ownerSize.width - frameSize.width) / 2, 65 ownerLoc.y + (ownerSize.height - frameSize.height) / 2); 66 } 67 68 71 public void flash() { 72 setVisible(true); 73 repaint(); 74 Timer cleanup = new Timer(PAUSE_TIME, new ActionListener() { 75 public void actionPerformed(ActionEvent e) { 76 dispose(); 77 } 78 }); 79 cleanup.setRepeats(false); 80 cleanup.start(); 81 } 82 83 } 84 | Popular Tags |