Monday, November 18, 2013

Splash Screen

Splash screen is a special window that displays in a short time period before the main window of a program or website shows. Generally, on the splash screen, you will see an image that represents an introduction to the program or website. Sometimes, a splash screen displays a progress bar to inform the user about a process that is loading and might take a long time to complete. When the process completes, the splash screen disappears.

In Java, you can use the SplashScreen class (in awt package) to create a splash screen for your program. Alternatively, you can write your own code to create a splash screen. In this tutorial, i prefer to do the latter. First of all, you will have a class that extends the JFrame class. This class will represent the splash screen. In this tutorial, i name it as SimpleSplashScreen. The splash screen has no border and title. So will use the setUndecorated method to hide border and title. On the splash screen, there is an image that provides introductory information of the program. The JLabel component is used to wrap the image. Then it will be added on the splash screen to show the image. In the SimpleSplashScreen class, you need to add two methods. The first method (wait) allows the user to set the time delay of the splash screen. Another method (showScreen) will be invoked in the program to display the splash screen. Simply, when the time is out, the splash screen disappears and the Welcome window is shown.

splash screen


This is the complete code of the SplashScreen program.

import java.awt.Container;
import java.awt.Font;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

class SimpleSplashScreen extends JFrame{
int delay=2000; //default delay time 2 seconds
SimpleSplashScreen(String imgfile){
ImageIcon iicon=new ImageIcon(imgfile);
int iwidth=iicon.getIconWidth();
int iheight=iicon.getIconHeight();
Container cont=getContentPane();
JLabel lbl=new JLabel();
//set time delay
public void wait(int mills){

public void showScreen(){
setVisible(true); //show the screen
try {
Thread.sleep(delay); //delay the screen
} catch (InterruptedException e) {
// TODO Auto-generated catch block
//close the SplashScreen when time out
new MaiInterface();

class MaiInterface extends JFrame{
setTitle("Your main interface here");
Container cont=getContentPane();
JLabel lbl=new JLabel("Welcome");
lbl.setFont(new Font("Arial", Font.BOLD,30));
public class SplashSr {
public static void main(String[] args){
SimpleSplashScreen sss=new SimpleSplashScreen("d:/splashscreen.png");


  1. Quite Interesting post!!! Thanks for posting such a useful post. I wish to read your upcoming post to enhance my skill set, keep blogging.
    Best JAVA Training in Chennai|JAVA Training

  2. I have read your blog its very attractive and impressive. I like it your blog.

    Java Training in Chennai Java Training in Chennai | Core Java Training in Chennai

    Online Java Training Java Online Training | Java J2EE Online Training | JavaEE Training Institute in Chennai

  3. Hibernate Online Training Hibernate Online Training Hibernate Training in Chennai Hibernate Training in Chennai Java Online Training Java Online Training

    Hibernate Training Institutes in ChennaiHibernate Training Institutes in Chennai Java Online Training Java Online Training

  4. Jave website such as this one really rocks! Sharing your knowledge to other people is really inspiring, because not all are java programmers, but anyone can learn the basics. Students from are really taking advantage of your post most of the time.

  5. Java Training Institutes Java Training Institutes Java EE Training in Chennai Java EE Training in Chennai Java Spring Hibernate Training Institutes in Chennai J2EE Training Institutes in Chennai J2EE Training Institutes in Chennai Core Java Training Institutes in Chennai Core Java Training Institutes in Chennai

  6. Java is programming language which is used in almost all the applications and games which are on the web. Java is being used extensively and it will be used extensively in near future. So getting trained in Java will surely be helpful.
    Java Training in Chennai | Java courses in Chennai | Java Training Institutes in Chennai

  7. This information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic.
    Hadoop Training Chennai|Big Data Training Chennai|Best Hadoop Training in Chennai

  8. It's really good to know that these java codings are still being used as reference of present and future java codes. Glad I was able to learn more here on how splash screen coding works.

  9. I like your writing style, it was very clear to understanding the concept well; I hope you ll keep your blog as updated.
    Best Institute for Cloud Computing in Chennai|Salesforce Training in Chennai

  10. The blog gave me idea about splash screen Thanks for sharing it
    Hadoop Training in Chennai

  11. Excellent post!!! In this competitive market, customer relationship management plays a significant role in determining a business success. That too, cloud based CRM product offer more flexibility to business owners to main strong relationship with the consumers. Salesforce Training Institutes in Chennai| Salesforce Training Institutes in Chennai


  12. In your blog I was happy to see your article, better than last time, and have made great progress, I am very pleased. I am looking forward to your article will become better and better.
    hotmail login | red ball |

  13. I just see the post i am so happy to the communication science post of information's.So I have really enjoyed and reading your blogs for these posts.Any way I’ll be replay for your great thinks and I hope you post again soon...
    Software Testing Training in Chennai

  14. really you have been shared very informative blog. it will be helpful to the peoples who are all working under the technology. so keep on sharing such kind of an interesting blog.
    hadoop training in chennai

  15. really you have posted an informative blog. it will be really helpful to many peoples. thank you for sharing this blog. before i read this blog i didn't have any knowledge about this. but now i got some knowledge.
    java training in chennai

  16. Hi admin..,
    First of i appreciate your coding knowledge. This is very nice. Iam really happy to command your blog because this is one of the nice blog for me. I gather lot of information from this blog.
    Thanks for sharing.

    Core Java Online Training

  17. Hi, I am a big follower of your blog. Really very informative post you shared here. Keep sharing this type of informative blog. Waiting for your next update. If anyone wants to become a Java professional learn Java Training in Bangalore. Nowadays Java has tons of job opportunities for all professionals.

  18. The information shared are very much useful My sincere Thanks for sharing this post please continue to share this post
    Java Training in Chennai

  19. Interesting and informative article.. very useful to me.. thanks for sharing your wonderful ideas.. please keep on updating..

    Java Training in chennai

  20. This article is very much helpful and i hope this will be an useful information for the needed one. Keep on updating these kinds of informative things...Want to build your website.
    White Label Website Builder

  21. Your details are very informative for me. I am interested to learn AngularJS Training in Chennai or AngularJS course in Chennai Do you have this kind of post means kindly share with me.

  22. Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.

    Java Training in Bangalore

  23. Crush and smash film or still pictures as 3D pieces detonate to uncover the following picture from Pixel Film Studios. With the 3D camera and lights in Movement 5, clients can produce their smash results to the following level. Turn, rotate or container around the media as it breakes into many minor pieces. FCPX Motion Plugins