Я получил Java ProgressBar, который отлично загружается, но я не вижу процесс, только результат.(когда бар закончил загрузку) Я хочу видеть каждый процент прогресса.Когда я запускаю код, появляется рамка, а индикатор прогресса - нет, только когда он на 100%.В чем проблема?
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
JFrame f = new JFrame("JProgressBar Sample");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container content = f.getContentPane();
progressBar = new JProgressBar();
progressBar.setStringPainted(true);
Border border = BorderFactory.createTitledBorder("Reading...");
progressBar.setBorder(border);
content.add(progressBar, BorderLayout.CENTER);
f.setSize(300, 100);
f.setVisible(true);
progressBar.setValue(0);
inc(); //fill the bar
//It fills, but I can't se the whole loading...
}
//Here's the filling path
public static void inc(){
int i=0;
try{
while (i<=100){
progressBar.setValue(i+10);
Thread.sleep(1000);
i+=20;
}
}catch(Exception ex){
//nothing
}
}