A splash screen for an application : Splash Screen « Swing JFC « Java






A splash screen for an application

   
 
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JWindow;

class SplashScreen extends JWindow {
  private int duration;

  public SplashScreen(int d) {
    duration = d;

    JPanel content = (JPanel) getContentPane();
    content.setBackground(Color.white);
    int width = 450;
    int height = 115;
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (screen.width - width) / 2;
    int y = (screen.height - height) / 2;
    setBounds(x, y, width, height);

    content.add(new JLabel("asdf"), BorderLayout.CENTER);
    Color oraRed = new Color(156, 20, 20, 255);
    content.setBorder(BorderFactory.createLineBorder(oraRed, 10));

    setVisible(true);
    try {
      Thread.sleep(duration);
    } catch (Exception e) {
    }
    setVisible(false);
  }
  public static void main(String[] args) {
    SplashScreen splash = new SplashScreen(10000);
  }
}

   
    
    
  








Related examples in the same category

1.A simple application to show a title screen in the center of the screenA simple application to show a title screen in the center of the screen
2.A simple Splash screen
3.Simple splash screenSimple splash screen
4.A progress bar indicating the progress of application initialization
5.Class representing an application splash screenClass representing an application splash screen
6.JSplash extends JWindow
7.Splash Screen based on JWindowSplash Screen based on JWindow
8.SplashScreen extends JWindowSplashScreen extends JWindow