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

welcome


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();
setSize(iwidth,iheight);
setLocationRelativeTo(null);
setUndecorated(true);
Container cont=getContentPane();
JLabel lbl=new JLabel();
lbl.setIcon(iicon);
cont.add(lbl);
}
//set time delay
public void wait(int mills){
delay=mills;
}

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

class MaiInterface extends JFrame{
MaiInterface(){
setSize(400,300);
setTitle("Your main interface here");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container cont=getContentPane();
JLabel lbl=new JLabel("Welcome");
lbl.setHorizontalAlignment(JLabel.CENTER);
lbl.setFont(new Font("Arial", Font.BOLD,30));
cont.add(lbl);
setVisible(true);
}
}
public class SplashSr {
public static void main(String[] args){
SimpleSplashScreen sss=new SimpleSplashScreen("d:/splashscreen.png");
sss.wait(5000);
sss.showScreen();
}
}

compass app flashLight app

131 comments:

  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.
    Regards,
    Best JAVA Training in Chennai|JAVA Training

    ReplyDelete
    Replies
    1. Great post.Thanks for one marvelous posting! I enjoyed reading it;The information was very useful.Keep the good work going on!!

      ETL Testing training in chennai| SAP MM training in chennai | Informatica training in chennai

      Delete
    2. The effectiveness of IEEE Project Domains depends very much on the situation in which they are applied. In order to further improve IEEE Final Year Project Domains practices we need to explicitly describe and utilise our knowledge about software domains of software engineering Final Year Project Domains for CSE technologies. This paper suggests a modelling formalism for supporting systematic reuse of software engineering technologies during planning of software projects and improvement programmes in Final Year Project Centers in Chennai.

      Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Spring Framework Corporate TRaining the authors explore the idea of using Java in Big Data platforms.
      Specifically, Spring Framework provides various tasks are geared around preparing data for further analysis and visualization. Spring Training in Chennai

      Delete
  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

    ReplyDelete
  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

    ReplyDelete
  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 http://bestessay.education/making-reaction-papers are really taking advantage of your post most of the time.

    ReplyDelete
  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

    ReplyDelete
  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.
    Thanks,
    Java Training in Chennai | Java courses in Chennai | Java Training Institutes in Chennai

    ReplyDelete
  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

    ReplyDelete
  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.

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

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

    ReplyDelete
  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

    ReplyDelete


  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 | 192.168.1.1

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete
  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.

    ReplyDelete
  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

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

    Java Training in chennai

    ReplyDelete
  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

    ReplyDelete
  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.

    ReplyDelete
  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

    ReplyDelete
    Replies
    1. Thanks for sharing your blog of information.Really a awesome post.keep on blogging.Selenium Training in Chennai |
      |Oracle Training in Chennai

      Delete
  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

    ReplyDelete
  24. Thanks for one marvelous posting! I enjoyed reading it; you are a great author. I will make sure to bookmark your blog and may come back someday. I want to encourage that you continue your great posts, have a nice weekend!


    Java Training in Chennai


    Java Training in Bangalore


    Java Training in Bangalore

    ReplyDelete
  25. I have read your blog. Your information is really useful for beginner. informations provided here are unique and easy to understandThanks for this useful infromation. QTP Training in Chennai
    Java Training in Chennai
    Python Training in Chennai

    ReplyDelete
  26. Technology is in a growing way, if you want to shine your career just try to learn a latest technology skill which is having great scope in future.
    Best hadoop training institute in chennai|Big Data Hadoop Training in Chennai

    ReplyDelete
  27. You've made some good points there. I looked on the internet for more information about this
    Mainframe Training In Chennai | Hadoop Training In Chennai | ETL Testing Training In Chennai

    ReplyDelete
  28. Nice Info!

    It is really a great and useful piece of info. I’m glad that you shared this helpful info with us. Thank you for sharing Final Year Bca Project Centres Chennai | ME Projects Chennai.

    ReplyDelete
  29. It is really a great and useful piece of info. I’m glad that you shared this helpful info with us. Thank you for sharing Bio Medical Inplant Training in Chennai.

    ReplyDelete
  30. Thank you for posting this beneficial content material. You provided another one great article in bsc mini projects in chennai. I hope this information may change my business carrier.I can remember these things whenever taking the decision in realtime mini projects in chennai.

    ReplyDelete
  31. Really you shared the information is great and useful.I have learned new things.you also refer this ME Projects Chennai | Ns2 Projects in Chennai.

    Thank You.

    ReplyDelete
  32. Hi Admin,
    I went through your blog and it’s totally awesome. Keep on updating your site with such informative post.

    ECE Project Centers in Chennai | Embedded Mini Project Centers in Chennai

    ReplyDelete

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

    Msc Project Centers in Chennai | Project Centers in Chennai.

    ReplyDelete
  34. It's interesting that many of the bloggers to helped clarify a few things for me as well as giving. Most of ideas can be nice content. The people to give them a good shake to get your point and across the command
    Java training in Chennai
    informatica training in chennai
    oracle training in chennai
    selenium training in chennai
    hadoop training in chennai
    unix training in chennai
    Python training in Chennai

    ReplyDelete
  35. Nice Blog, Thanks for sharing this valuable one.This is very useful for me and gain more information,

    Angularjs Training in Chennai | Dot Net Training in Chennai

    ReplyDelete
  36. It's a nice post. Thank you for sharing this useful information. Keep up the good work.

    IoT Training | IoT Courses

    ReplyDelete
  37. Thanks for making me this article. You have done a great job by sharing this content in here. Keep writing article like this.

    Mobile Apps Training
    Mobile Apps Training in Chennai

    ReplyDelete
  38. Very Nice Article to read. Blog articles helped me alot in many ways to find the good solution. Am very happy to comments here. Thanks for sharing this kind of wonderful article in this blog. Lovely ! MATRIX dealers

    ReplyDelete
  39. Amazing article. Your blog helped me to improve myself in many ways thanks for sharing this kind of wonderful informative blogs in live. I have bookmarked more article from this website. Such a nice blog you are providing ! Kindly Visit Us @ Best Travels in Madurai | Tours and Travels in Madurai | Madurai Travels

    ReplyDelete
  40. Thanks for sharing this unique information with us. Your post is really awesome. Your blog is really helpful for me..
    organic oil
    organic oil in jaipur
    organic cold pressed oils
    ayurvedic oil store in jaipur

    ReplyDelete
  41. Unquestionably believe that which you said. Your favorite justification seemed to be on the web the easiest thing to be aware of. I say to you, I definitely get irked while people think about worries that they just don't know about. You managed to hit the nail upon the top and also defined out the whole thing without having side effect , people can take a signal. Will likely be back to get more. Thanks seo service

    ReplyDelete
  42. Thanks for sharing this unique information with us. Your post is really awesome. Your blog is really helpful for me..
    organic oil
    organic oil in jaipur
    organic cold pressed oils
    ayurvedic oil store in jaipur

    ReplyDelete
  43. You made some nice points there. I did a search on the subject and found most persons will approve with your site.online marketing

    ReplyDelete
  44. I needed to put you that little bit of word to give thanks as before regarding the awesome techniques you have discussed on this website. It's certainly tremendously open-handed with you in giving extensively all that numerous people could possibly have sold as an e book to earn some profit for themselves, and in particular now that you could possibly have tried it in the event you decided. These ideas likewise worked like a fantastic way to realize that someone else have a similar desire much like my own to figure out good deal more with reference to this matter. Certainly there are thousands of more pleasurable times ahead for those who read carefully your blog post.online marketing company

    ReplyDelete
  45. Iíve learn a few good stuff here. Certainly value bookmarking for revisiting. I wonder how so much effort you place to make the sort of excellent informative site. truck rental singapore

    ReplyDelete
  46. Howdy! I could have sworn I've been to this site before but after reading through some of the post I realized it's new to me. Anyways, I'm definitely delighted I found it and I'll be book-marking and checking back frequently! robotic systems integration

    ReplyDelete
  47. Hi my friend! I wish to say that this article is awesome, nice written and include almost all important infos. I would like to see more posts like this. sell your property

    ReplyDelete
  48. Great post. I was checking continuously this weblog and I am inspired! Very helpful info specifically the last phase :) I care for such information much. I used to be seeking this certain info for a long time. Thanks and best of luck. temporary fence hire prices

    ReplyDelete
  49. That is really interesting, You're a very professional blogger. I've joined your rss feed and look forward to looking for extra of your wonderful post. Additionally, I've shared your website in my social networks!preschool moorebank

    ReplyDelete
  50. Useful info
    Unic Sol is the best java training in Hyderabad with job placements. Along with java training full stack, mean stack, angular & testing tools training is provided by industry experts. We are the best java training in Hyderabad.

    ReplyDelete


  51. Great Article. This Blog Contain Good information about ERP Software. Thanks For sharing this blog. Can you please do more articles like this blog.


    machine maintenance software price in us
    machine maintenance software development in us
    crm software development cost in us
    erp in chennai
    crm software development cost in chennai
    cloud erp in chennai

    ReplyDelete
  52. This comment has been removed by the author.

    ReplyDelete
  53. This is really an amazing and thank you so much for sharing

    คาสิโนออนไลน์ที่น่าเชื่อถือและมีความเป็นมืออาชีพที่สุดในตอนนี้
    โปรโมชั่นGclub ของทางทีมงานตอนนี้แจกฟรีโบนัส 50%
    เพียงแค่คุณสมัคร สล็อตออนไลน์ กับทางทีมงานของเราเพียงเท่านั้น
    ร่วมมาเป็นส่วนหนึ่งกับเว็บไซต์คาสิโนออนไลน์ของเราได้เลยค่ะ
    สมัครสล็อตออนไลน์ >>> Goldenslot
    สนใจร่วมสนุกกับ คาสิโนออนไลน์ คลิ๊กได้เลย
    มีทั้งคาสิโนออนไลน์ หวยออนไลน์ ฟุตบอลออนไลน์ สล็อตออนไลน์ และอื่นๆอีกมากมาย

    ReplyDelete
  54. Thank you so much for this useful article. Visit OGEN Infosystem for Web Designing and SEO Services in Delhi, India.
    Website Designing Company

    ReplyDelete
  55. Is there anyone who can recommend the best service among the ones listed here for google seo class in singapore?

    ReplyDelete
  56. Appslure is a reputed company based in India which provide mobile app development company in mumbai. Our website's layout will be very attractive and responsive, which will gain more visitors and you can get high lead and business from your website. Wonderful post, This article have helped greatly continue writing ..
    Mobile app development company in mumbai

    ReplyDelete
  57. http://java.worldbestlearningcenter.com/2013/11/splash-screen.html?showComment=1571826500170#c124646149514112925

    ReplyDelete