24 May 2011

Infinite JProgressBar Tutorial


Infinite JProgressBar Tutorial
Hello Friends,

Nice to see you again.
In Previous Session we have seen JProgressBar Tutorial. In which We created a class which shows JProgressBar
with painted String on it. That type of JProgressBar is used in some sort of situation where we know how much time user have to wait for some process to be completed.

But there can be  some  circumstances where we dont know how much time user will have to wait for some process to be completed,
in this type of situation we have to use Infinite JProgressBar or say Indeterminant  JProgressBar.

So, Today we will learn Infinite JProgressBar in Java Swing.


So be ready to learn this simple exmaple of Infinite JProgressBar .
After apply this code in action, you will be capable of using Infinite JProgressBar in your Swing Applications.

Output will be like this:








OK For this you have to create one class called InfiniteProgressBar.java and paste the below code in it.
And run it....Simple right..?


-------------------------------------------------------------------------------------------------------------

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

public class InfiniteProgressBar {
public static void main(String[] args) {

JFrame f = new JFrame("Progress");
JProgressBar p = new JProgressBar();

p.setIndeterminate(true);
p.setPreferredSize(new Dimension(300,30));
f.getContentPane().add(p);

f.pack();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);

}
}
--------------------------------------------------------------------

So I hope this code is helpful in understanding the working of Infinite JProgressBar.


Feel free to ask me if you have any dought regarding this.
You can also give me suggessions to improve this tutorial.


Leave comments if you like this post...!


Thank you.
Nirav Raval


----------------------------------------------------------------------------------
Follow Other Java Swing Tricks....

2 comments:

Leave Comment If You Like This...Thank You..!