Following this guide I want to add a JProgressBar in my application while a long PDF document is being created after the apposite button is pressed. This is a skeleton of my method:
/* asking data to database and getting a list of Objects */
JFrame frameBar = new JFrame("Avanzamento");
Container content = frameBar.getContentPane();
JProgressBar progressBar = new JProgressBar();
progressBar.setValue(0);
progressBar.setStringPainted(true);
Border border = BorderFactory.createTitledBorder("Creazione report PDF in corso");
progressBar.setBorder(border);
content.add(progressBar);
frameBar.setSize(600, 200);
frameBar.setVisible(true);
int length = results.getProtocolloList().size();
for (int j = 0; j < length; j++) {
/* print object j-th in a table into the PDF Document */
progressBar.setValue((length / 100)*j);
Thread.sleep(1000);
}
frameBar.setVisible(false);
frameBar.dispose();
Anyway nothing is showed in the frameBar, what I see is just a blank window without anything. Do you know where am I making the mistake?