Hi,
i would like to show a JProgessBar during a longer process. I can show
it, but I cannot get the JProgressBar to update the UI, so it just
appears and at the end it disappears again, but it's not changed in the
meantime.
Example code, JProgressBar in JDialog, Java 1.4.2:
public class DialogProgressBar extends JDialog {
private JProgressBar jpb;
public DialogProgressBar(String title, java.awt.Frame owner, boolean
modal) {
super(owner, title, modal);
jpb = new JProgressBar();
jpb.setStringPainted(true);
this.getContentPane().add(jpb, java.awt.BorderLayout.CENTER);
setSize(300,50);
}
public JProgressBar getProgressBar() {
return jpb;
}
}
and that's how I use the Dialog/JProgressBar.
...
DialogProgressBar pb = new DialogProgressBar("Titel", dialog, false);
...
public void actionPerformed(ActionEvent aE) {
...
else if(cmd.equals("mniSynchronize")) {
int selectedRows = 3;
pb.getProgressBar().setMinimum(0);
pb.getProgressBar().setValue(0);
pb.getProgressBar().setMaximum(selectedRows);
pb.setVisible(true);
for(int i=0;i<selectedRows;i++) {
switch(i) {
case 1: pb.getProgressBar().setString("file001");
storeFiletype001();
break;
case 2: pb.getProgressBar().setString("file002");
storeFiletype002();
break;
case 3: pb.getProgressBar().setString("file003");
storeFiletype003();
break;
}
pb.getProgressBar().setValue(i+1);
}
pb.setVisible(false);
}
}
Thanks,
Aloys
Andrew Thompson - 05 Nov 2004 13:24 GMT
> I can show it, but I cannot get the JProgressBar to update the UI, ..
Probably..
<http://www.physci.org/guifaq.jsp#2.1>
Note: Follow-Ups set to c.l.j.help.

Signature
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane