Code:
private void loading(String arg0) {
frame.setSize(260,70);
frame.setLocation((java.awt.Toolkit.getDefaultToolkit().getScreenSize().width-frame.getWidth())/2,(java.awt.Toolkit.getDefaultToolkit().getScreenSize().height-frame.getHeight())/2);
JProgressBar load = new JProgressBar();
load.setMaximum(200000);
load.setValue(0);
load.setVisible(true);
load.setLocation(15, 10);
load.setSize(180, 20);
container.removeAll();
container.add(load);
container.validate();
container.repaint();
for(int i=0; i<=20000;i++) {
load.setValue(load.getValue()+1);
new Thread(){
public void run() {
super.run();
try {
Thread.sleep(20);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}.start();
}
}