Progress Bar in Java

This page discusses - Progress Bar in Java


How to convert String Date to Timestamp in Java? Best Java Tutorial for Beginners Read user input in Java using Scanner Java Programming Examples Read file line by line in Java 8 What are the benefits of learning Java Programming? A brief history and future of Java programming language Importance of Java for Mobile Application Development How To Become A Good Software Developer? Learn Java Programming for beginners 5 Reasons Java is Still a Great Language to Boost Your Career Prospect as a Programmer How to learn Java with no programming experience? How to learn Java? What are Classes and Interfaces in Java? Converting a String to Integer in Java How to check if a string exists in a string in JavaScript? Installing JDK 8 on Windows 10 and configuring the settings Video Tutorial of reading file in Java 9 Invincible Reasons to learn Java New to Java programming Java Programming Tips, Articles and Notes How to download JDK 1.6? Encapsulation in Java Programming How to format number in Java? Generics Example Program in Java Java 9 Features Java 9 Tutorial, news and examples How to read content of JPEG file in Java? Image Processing Tutorials in Java Programming Language Introduction to Java Technology Java 8 Consumer Interface with forEach Loop Introduction to Generics in Java Java 8 consumer class(interface) example Oracle Launches Project Valhalla for Java How to read properties file in Java? How to add JDK 8 support in Eclipse? Java 8: Java 8 is officially released and it can be downloaded How to Invoke method using Reflection API of Java? First Lambda Expressions in Java Java 8 expected release date

Progress Bar in Java


Progress Bar is a component used to show the status of the application that how much time is left in order to complete the task of a specified application. In Java Progress Bar is created using swing. The Swing Class used for the implementation of Progress Bar is JProgressBar Class

Code Description 

In this Tutorial we want to describe you a program code that helps you in the implementation of Progress Bar in Java. This Program provides you how a Progress Bar show the status of your running application in progress.

The Program shows you a Class name' Progress Bar' with a button labelled with a name ' go'.

1)set String Painted- This is a Method that  will provides you the complete progress in percentage of the Progress Bar. This method takes Boolean as parameter. The value set to be true to see the status on progress bar, otherwise the status of progress bar would not be visible.

2)setValue( )- This Method provides you to set the value of the Progress Bar.

3)iterate( )-  This Method provides you if variable name  num is less than  1000 millisecond in while loop then it set the current thread to execute in Progress Bar, otherwise it would execute  the try block that remain thread to call sleep ( )method and remain inactive for 500 milliseconds, that is subsequently handled by catch block.


   import java.awt.*;
   import java.awt.event.*;
   import javax.swing.*; 

  public class ProgressBar extends JFrame
  JLabel l1;
  JProgressBar current;
   JTextArea ta;
   JButton bu;
   Thread runner;
   int num = 0;

  public ProgressBar() 

   JPanel pane = new JPanel();
   bu = new JButton("go");
   pane.setLayout(new GridLayout());
   current = new JProgressBar(0, 100);

   public void iterate()
   while (num < 1000) 
   catch (InterruptedException e)

  num += 90;

  public static void main(String[] arguments) {
  ProgressBar frame = new ProgressBar();
  frame.iterate( );


Output on Command Prompt


C:\saurabh>java ProgressBar


On Execution of the Program code ,The Progress Bar display as follows


Share on Google+Share on Google+

Progress Bar in Java

Posted on: April 17, 2011 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: Progress Bar in Java  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image