Source Code : Implement a progressbar in your application
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Implement a progressbar in your application
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.SwingUtilities;
public class Main extends JPanel {
JProgressBar pbar;
static int min = 0;
static int max = 100;
public Main() {
pbar = new JProgressBar();
pbar.setMinimum(min);
pbar.setMaximum(max);
add(pbar);
JFrame frame = new JFrame("Progress Bar Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setContentPane(this);
frame.pack();
frame.setVisible(true);
for (int i = min; i <= max; i++) {
final int percent = i;
try {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
updateBar(percent);
}
});
Thread.sleep(100);
} catch (InterruptedException e) {
}
}
}
public void updateBar(int newValue) {
pbar.setValue(newValue);
}
public static void main(String args[]) {
new Main();
}
}
Thank with us