Archive

Archive for July, 2013

How to develop a progress bar in Java Swing using NetBeans IDE Drag and Drop Form.

import javax.swing.SwingUtilities;

public class Welcome extends javax.swing.JFrame {

Thread t = null;

public  Welcome() {
super(“Welcome”);
initComponents();
try
{

Thread t1 = new Thread()
{
public void run()
{
int i = 0;

while (i <= 100) {
jProgressBar1.setValue(i);

try
{
sleep(90);
}
catch (InterruptedException ex)
{

}
i++;
}
}
};
t1.start();
}
catch (NullPointerException e)
{
System.out.println(“Retrieving Data Fail”);
}
}

@SuppressWarnings(“unchecked”)

private void initComponents() {
//Code Hidden
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) throws InterruptedException      {
Welcome s=new Welcome();
s.setVisible(true);
Thread t=Thread.currentThread();
t.sleep(10000);
s.dispose();
SwingUtilities.invokeLater(new Runnable(){
public void run()
{
new nextform().setVisible(true);
}
});
}

private javax.swing.JPanel jPanel1;
private javax.swing.JProgressBar jProgressBar1;

}

Download the complete source code from here:-

http://www.mediafire.com/download/ajt18mzrzsrkdfx/Progressbar.rar

Categories: Uncategorized