Salve a tutti.Ho problema con l' aggiornamento di una JProgressBar
Il codice è questo :
codice:
public class ProgresBar extends JDialog implements IWindow{
     
     private JProgressBar progresBar;
     private JPanel panelProgresBar;
       
   public ProgresBar(JFrame frame){
       super(frame,"Progres bar",true);
       this.setResizable(false);
       this.setDefaultCloseOperation(this.DO_NOTHING_ON_CLOSE);
       this.setBounds(450, 300, 400, 100);
       this.progresBar = new JProgressBar();
       this.panelProgresBar = new JPanel();
       this.progresBar.setMinimum(0);
       this.progresBar.setMaximum(100);
       this.panelProgresBar.add(this.progresBar);
       this.getContentPane().setLayout(new BorderLayout());
       this.getContentPane().add(BorderLayout.NORTH,new JLabel("             Wait please......"));
       this.getContentPane().add(BorderLayout.CENTER,this.panelProgresBar);
       }

    
   public void updateBar(int newValue){
       this.progresBar.setValue(newValue);
   }
   public int getValueBar(){
       return this.progresBar.getValue();
   } 
    
    public void showWindow() {
        this.setVisible(true);
    }
}

Aggiornamento poi dovrebbe essere fatto in un action performed o in altra classe con il codice:

codice:
 for (int i = 0; i <= 100; i++) {
      final int percent = i;
      try {
        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            pb.updateBar(percent);
          }
        });
        java.lang.Thread.sleep(100);
      } catch (InterruptedException e) {
        ;
      }
    }
Ma non succede niente,qual'è il problema?
Inoltre vorrei far in modo che sia sincronizzata la scrittura su file.