Progress Monitor doesn't update

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ssaraceni
    New Member
    • Sep 2008
    • 18

    Progress Monitor doesn't update

    Hi, I'm trying to use a ProgressMonitor in my Java application, to show information during a long process, but is only visible the title and the frame of the ProgressMonitor .

    Code:
    public static void updateProcess(){
                ... 
    //code
                ....
                    ProgressMonitor progressMon=new ProgressMonitor(null, "Operation in progress...", "", 0, 3600);
                    progressMon.setProgress(0);
                    ....
                    progressMon.setProgress(1);
                    progressMon.setNote("note1");
                    ......
    I call the updateProcess procedure when user clicks on a button, but the ProgressMonitor appear only some seconds after starting updateProcess and doesn't shown or update the progress bar.

    What's wrong in the code? thanks
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Most likely your updateProcess() method runs in the AWT EDT (Event Dispatch Thread).
    Is that method started from some actionEvent() method or alike?

    kind regards,

    Jos

    Comment

    • ssaraceni
      New Member
      • Sep 2008
      • 18

      #3
      yes, the method is started from an actionlistener, that handles actions for some buttons on a panel of my GUI.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by ssaraceni
        yes, the method is started from an actionlistener, that handles actions for some buttons on a panel of my GUI.
        Ok, run your updateProcess() in a separate thread then so it won't stop that EDT
        thread anymore.

        kind regards,

        Jos

        Comment

        • ssaraceni
          New Member
          • Sep 2008
          • 18

          #5
          Originally posted by JosAH
          Ok, run your updateProcess() in a separate thread then so it won't stop that EDT
          thread anymore.

          kind regards,

          Jos
          I've created a new Thread into actionPerformed that calls the method, :
          Code:
          class ButtonHandler implements ActionListener{
          		public void actionPerformed (ActionEvent e){
          ....
          Thread op=new Thread(){                                         
          public void run(){                                             Global.updateProcess();                                         
          }                                     
          };                                     
          op.start();
          but the problem still remain, now the progressMonitor isn't show. I've also set the setMillisToPopu p property to 0, but the progressMonitor isn't show.

          In the updateProcess, after some instructions I've a Thread.sleep(30 00); but the method ends without the progressMonitor shown. What's the matter?

          Comment

          • JosAH
            Recognized Expert MVP
            • Mar 2007
            • 11453

            #6
            Originally posted by ssaraceni
            What's the matter?
            I don't know; in the API documentation for the ProgressMonitor there's a link to
            the appropriate section of the tutorial. There's a ProgressMonitor Demo in there.
            Check it out.

            kind regards,

            Jos

            Comment

            Working...