Java Splash Screeen With Progress Bar Tutorial | Full Source Code

Today we will learn how to create Java Splash Screen With Progress Bar using Swing. The splash screen is nothing but a start-up loading screen of any software or application and usually contains a logo or other images. 

A splash screen is beneficial when we have to load our application, and we know it will take some time. So in that duration, we can show a splash screen to our user so that the user will feel some process is going on. It gives a professional look to our application.

After going through this post, you will be able to make a splash screen in Java or Java loading screen for your application, and there are several ways by which you can make it more attractive.

I am going to use IntelliJ IDEA IDE for the coding part of my program. You can use any IDE like NetBeans or eclipse. So let’s start our tutorial and learn How To Create Java Splash Screen With Progress Bar using Swing step by step .

Also Read –  Login Form in Java Swing

Java Splash Screen With Progress Bar | Java Loading Screen

Creating Display For Our Screen

step 1 

  • So in the very first step, we need to create a display for our screen.Simply create a new project and add a new class to your project(MainClass in this example).
  • Now create main() method inside that class.
  • Now add another class to your project (SplashScreenDemo in this example).
  • Now to create a display screen for our splash screen, we have to create an object of JFrame class, and we will set some of its properties like its layout, visibility, location, size etc.
  • Now we don’t want title bar in our JFrame so that it will give a feel of the splash screen.
  • For this, we will call a method setUndecorated() using the object of JFrame and it takes a boolean value in its parameter so we will pass true in its parameter for removing the title bar.
  • Now create an object of SplashScreenDemo inside main() method of MainClass.
  • Now Run your program.
Java Splash Screen With Progress Bar
Java Splash Screen With Progress Bar – fig-1
  • As you can see that we have built our screen without title bar.
  • Now in next step, we will add an image to our screen.

Adding Image To Screen

Step 2

  • To add an image to our Screen, we will Create an object of the JLabel class and in its constructor, we will add the specified image using the ImageIcon class.
  • Now we will set the size of the image using the setSize() method and then we will add it to the screen using the add() method.
  • Now Run your program.
Java Splash Screen With Progress Bar – fig-2
  • As you can see that we have added image to the screen.
  • Now in next step, we will add some texts to our screen.

Adding Texts To Screen

Step 3

  • To add texts to our screen, we will again create an object of the JLabel class and in its constructor we will pass the text that we want to add.
  • Next, we will set some of its properties like its size and location, its font properties, its foreground color and then we will add it to the frame.
  • Now run your program.
Java Splash Screen With Progress Bar – fig-3
  • As you can see that we have successfully added text to the screen.
  • Now in next step, we will add a progress bar to our screen.

Adding Progress Bar To Screen

Step 4

  • To add a progress bar to our Screen, we will create an object of the JProgressBar class and next we will set some of its properties.
  • Now Run your program.
Java Splash Screen With Progress Bar – fig-4
  • As you can see that we have added progress bar to our screen.
  • Now we want that if we run our program, then the progress bar should be running and it will give us an effect that some process is going on.
  • For executing this we will create a loop from integer value 1 to 100 and we will set the value of progress bar to that integer value and we will also pause the execution of the thread for some milliseconds using the sleep() method so that progress bar will be paused for some milliseconds and then it will execute.
  • For giving it a more professional look, I am also going to create a JLabel to the screen that will give us a message that how much process is being loaded.
  • Now Run your program.
Java Splash Screen With Progress Bar
  • As we can see from the above animation, we have successfully created our splash screen.
  • You can also download the source code of this Project. download link is given below..

Splash Screen Java Source Code

  • Here you can download the source code of Java Swing Splash Screen with Progress Bar.
  • The link of the file is given below.

So guys this was all from this post and if you have any doubts regarding this post then you can comment below. You can also check my previous post Registration Form in Java With Database Connectivity

People are also Reading…..

4 thoughts on “Java Splash Screeen With Progress Bar Tutorial | Full Source Code”

Leave a Comment