Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / November 2004

Tip: Looking for answers? Try searching our database.

JPogressBar does not update UI

Thread view: 
Ao - 05 Nov 2004 13:18 GMT
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



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.