Advertisement
smbarbour

Splash

Feb 22nd, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.39 KB | None | 0 0
  1. package org.smbarbour.mcu;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.EventQueue;
  5. import java.awt.Graphics;
  6. import java.awt.image.BufferedImage;
  7. import java.io.File;
  8. import java.io.IOException;
  9. import java.net.URL;
  10.  
  11. import javax.imageio.ImageIO;
  12. import javax.swing.Icon;
  13. import javax.swing.JFrame;
  14. import javax.swing.JLabel;
  15. import javax.swing.JPanel;
  16. import javax.swing.border.EmptyBorder;
  17.  
  18. import org.smbarbour.mcu.util.MCUpdater;
  19.  
  20. public class SplashForm extends JFrame {
  21.  
  22.     private MCUApp _mcu;
  23.  
  24.     /**
  25.      * Create the frame.
  26.      */
  27.     public SplashForm(MCUApp mcu) {
  28.         _mcu = mcu;
  29.         this.setUndecorated(true);
  30.         this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
  31.         JPanel pane = (JPanel)(this.getContentPane());
  32.         pane.setLayout(new BorderLayout());
  33.         this.setSize(320, 240);
  34.         this.setLocationRelativeTo(null);
  35.         pane.add(new JLabel("Loading..."), BorderLayout.SOUTH);
  36.        
  37.         getContentPane().add(new ImagePanel(SplashForm.class.getResource("/mcu-splash.png")), BorderLayout.CENTER);
  38.         pane.invalidate();
  39.         this.setVisible(true);
  40.     }
  41.  
  42.     class ImagePanel extends JPanel{
  43.  
  44.         private BufferedImage image;
  45.        
  46.         public ImagePanel(URL resource) {
  47.             try {
  48.                 image = ImageIO.read(resource);
  49.             } catch (IOException ex) {
  50.             }
  51.         }
  52.        
  53.         @Override
  54.         public void paintComponent(Graphics g) {
  55.             super.paintComponent(g);
  56.             g.drawImage(image, 0, 0, null);
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement