Progress Monitoring

Hi all,
I need to set up a ProgressMonitor so to display the progress on the main task of my program. this is pretty complex and goes beyond my program, involving others tools. How can i monitorate it? In the example which i saw, in the tutorial and in the Swing Book, i just saw how to make it goes with a Timer, but it's far from an application task progress..!
How can i deal with this?
thank you,
regards
marco

1. Destroying the old dialog box"old dialog box".dispose();
3. creating the JProgressbar and making it
indeterminateBetter create JProgressBar object before starting the thread.
2. Starting the long task
4. Destroying the JProgressBar
5. informing the user that the task is completeIn your class, define the SwingWorker as:
    final SwingWorker worker = new SwingWorker() {
        public Object construct() {
            /* start your long task.
             * Call local method, method from other
             * class, whatever.
            return new Object();
        public void finished() {
            /* To finish off the long task.
             * This method is called when the thread
             * finishes.
             * This where you destroy your progress bar
             * and inform user the task is completed.
    };Of course, you'll need another thread to monitor the progress of your task, and increment the value in progress bar.
As for indeterminate progress bar, you'll need to know some estimate anyway.
If at all possible to break the long task in blocks/sections, that number can be applied to the progress bar. Otherwise, get an average performance time, and set the maximum with a figure, and slowly increment the progress bar. If it reaches 99% before finish, then I guess you have to wait till the task ends, then display 100%. If finishes quickly, then you can boost the speed of increment (or instantly display 100%).
Alternatively, if you can determine (dynamically) how long before the end of task while running your task, you can always update your JProgressBar values (you probably aware of this, anyway).
Hope this helps.

Similar Messages

  • What's wrong with my Progress Monitor and how do I fix it?

    Hello,
    My progress monitor fails to draw its insides, except when the task is already finished
    Inside a class that extends SwingWorker<Void, Void> ...
         @Override
         public Void doInBackground() throws Exception
              try
                   this.progressMonitor = new ProgressMonitor(jPanelControl,
                             "Running a Long Task",
                             "", 0, data.size());
                        //jPanelControl.invalidate();
                        progressMonitor.setMillisToPopup(500);
                        progressMonitor.setMillisToDecideToPopup(100);
                   this.doProcess();
              catch (Throwable e)
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              return null;
         }doProcess goes on a little journey until we get to:
                      progressMonitor.setNote("Importing " + this.title);
            for (int i = start; i < this.data.size(); i++)
                   progressMonitor.setProgress(i);
                            //doing stuff each iterationQuickly after loading begins the box appears but it's not drawing the graphics inside the window (see screenshot for more)          
    btw: That white background is Java3D, could it be interfering with the way Swing updates graphics?
    Edited by: loza on Aug 25, 2009 4:03 AM

    Hi,
    take a look at [this sample from java tutorial|http://java.sun.com/docs/books/tutorial/uiswing/examples/components/ProgressBarDemoProject/src/components/ProgressBarDemo.java] ;
    Regards,
    Alan Mehio
    London,UK

  • Need configure guide for job progress monitor in JSM

    Hello Guys,
    I have received  an requirement to setup job progress monitoring in JSM(job schedule monitor).i have done my search in Google for configuration guide, but i could not find it.
    My Requirement:- i need to monitor the jobs progress(running on manage system) which consists on nearly 10 setps.End user need to monitoring the job progress  using PI diagram.
    Guys  if any one of you have done this setup please help me with configuration setps.
    Please provide your inputs on this.
    Regards,
    Pavan

    Hi Pavan,
    That should have been my place from where I would have start
    I hope Jansi, Prakhar or Karthik can redirect you on this.
    Meanwhile, If I get any thing, I will share it.
    Regards

  • Adding progress Monitor

    HI All,
    I have been working with reading an XML file through a local path, and sending it to the server via a web service
    The code is something like this:-
    String strnewpath = vecPathPLS.elementAt(insel).toString();
    FileInputStream finpStream = new FileInputStream(strnewpath);
    len = finpStream.available();
    for(int i=1; i <= len; i++)
                                  postxml = postxml+(char)finpStream.read();
    //This postxml will be sent as a parameter to the webservice method"post"My problem is I have to add a progress monitor or a progress bar while the file input stream is getting read in postxml.
    I dont know how this can be done.
    Any help and code snippets from your side will really help me out
    Thanks a lot
    Shikha

    this thread from a couple of days back might help
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=708732

  • Deployment Progress Monitor

    Once I start the application using "Debug" or "Run", the Deployment Progress Monitor will show the messages:
    "Starting Application" ...
    "asadmin -start-domain ...."
    and then this status window will be kept open even with "Automatically close" set. As result of that, the Web browser is never opened by Creator.
    There isn't any error message in server.log. The server is started and I can open the first page typing the URL. I checked and the path to the default browser is correctly set in the Creator "options" setting.
    There are two problems that result of the above situation:
    1) The browser will not be open with the first page;
    2) Even that I use "Debug" to start the application, I can't debug it, breakpoints will not work;
    Thxs

    Yes, if one starts the app server outside Creator. It will be much more stable and the monitor window will not hang.
    Also, it is good to check doman.xml. Sometimes the application name is not set correctly in context-name.
    Finally, If Creator begins to not be able to start the App Server, one also canjava, javaw, rundll and extra runide process in the Task Manager.
    Thanks.

  • How to use  Progress Monitors?

    how to use Progress Monitors?
    in the name of god
    hi friends
    i have a problem. I am writing a program that read data from a file record by record and store to a database. my problem is here that i want add a progress monitor that when the program is doing its work it appear. I use ProgressMonitorInputStream class but it can not work well. It appear and read file record by record and store in table of database but its progress don’t move and do nothing. I know that I have a tiny problem in use this class. Please guide me.
    i put my codes below.
    best regards
    *////this is an event that invoke my classes*
    private void readbtnActionPerformed(java.awt.event.ActionEvent evt) {                                       
            JFileChooser fileChooser = new JFileChooser();
            fileChooser.setCurrentDirectory(fileName);
            //filtering file extension
            FileNameExtensionFilter filter = new FileNameExtensionFilter("Text file", "txt");
            fileChooser.setFileFilter(filter);
            //fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
            int result = fileChooser.showOpenDialog(this);
            if (result == JFileChooser.APPROVE_OPTION) {   //if choose ok button
                fileName = fileChooser.getSelectedFile();
                ReadTextFile readFile = new ReadTextFile(fileName);
                readFile.openFile();
                readFile.readRecord();
                *//readFile.closeFile();       //if  this line enable this message appeare "Scanner closed" .why?*      
                readFile.closeFile();
            } else //if choose cancel button
                result = 0;     //do nothing
    */////this is readFile class and invoke data access class and insert data in my database*
    public class ReadTextFile {
        private Scanner input;
        private File fileName;
        private int i = 1;
        DataAccess dal = new DataAccess();                     //new a defined my class
        AcountRecord record = new AcountRecord();
        public ReadTextFile(File n) {       //Constructor
            fileName = new File(String.valueOf(n));
            this.openFile();
        private void setRecord(String val) {
            try {
                record.setId(Integer.parseInt(val.substring(1, 5)));
                record.setTime(Integer.parseInt(val.substring(8, 12)));
                record.setDate(Integer.parseInt(val.substring(15, 21)));
                record.setMode(val.substring(24, 26));
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, "ÇäÊÎÇÈ ÔãÇ äÇÏÑÓÊ ÇÓÊ.","Set Record Method",JOptionPane.ERROR_MESSAGE);
        public void openFile() {
            try {
                input = new Scanner(fileName);
            } catch (FileNotFoundException e) {
                JOptionPane.showMessageDialog(null, "ÇäÊÎÇÈ ÔãÇ äÇÏÑÓÊ ÇÓÊ.","Open File Method",JOptionPane.ERROR_MESSAGE);
        public void readRecord() {
            new Thread() {
                private Component _Main;
                @Override
                public void run() {
                    try {
                        input = new Scanner(fileName);
                        InputStream in = new FileInputStream(fileName);
                        ProgressMonitorInputStream pm =
                                new ProgressMonitorInputStream(_Main, "reading the file", in);
                        ProgressMonitor pmo = pm.getProgressMonitor( );
                        pmo.setMaximum( (int) fileName.length());
                        while (/*input.hasNext() &&*/ pm.read() != -1) {
                            setRecord(input.next());
                            dal.Connect();
                            String sql = "INSERT INTO fileinfo(pkey,id,date,time,mode)VALUES(%s,%s,%s,%s,'%s')";
                            sql = String.format(sql, i++, record.getId(), record.getDate(), record.getTime(), record.getMode());
                            dal.doCommand(sql);
                    } catch (Exception e) {
                        JOptionPane.showMessageDialog(null, e.getMessage() ," Read Record method.",JOptionPane.ERROR_MESSAGE);
                    dal.Disconnect();      
            }.start();
        public void closeFile() {
            input.close();
    }Edited by: firethumbs on Mar 26, 2009 12:43 PM

    IN THE NAME OF GOD
    hi firends
    i forget say one thing. if remove while loop content this program will work good. i suppose that the while condition and read file records not similar. because while condition check bytes but in while body read records. is that true?
    how can solve this problem?
    best regurds

  • Progress Bar or Progress Monitor for a system command

    Hello,
    I am running a DOS copy command in a Java Swing application. I understand that I
    can implement a Progress Bar or a Progress Monitor if I open the first file, read it,
    and write to a second file. But if I have a need to use the DOS copy command,
    is there a way to implement a Progress Bar or a Progress Monitor for it. If there is,
    could you please point me to some example code?
    Thank you,
    Chris

    Hello Chris,
    you would have to write some native code which peeks or watches the DOS process and its progress. Surely not an easy task. But without that information, how will you set values for the ProgressMonitor?
    What you could do, however, is showing an Indeterminate JProgressBar at DOS process start and make it disappear at process end.

  • Trouble in implementing a progress monitor?

    I need a lot of calculation when I click start button, so, I made a thread using SwingWorker class, this thread is responsible for the calculation. I need a progress monitor to display the progress of the calculation, so, do I need another thread to do it? How can I do it? Any suggestion is great appreciated.
    The following is the schetch of my class.
    // this class do the calculation
    // these stuff is within my button listener
    MyClass my = new MyClass(...);
    my.go();
    // stuff in go() method of MyClass is :
    final SwingWorker worker = new SwingWorker() {
    void construct(){
    // Do calculation
    void finished(){}
    How to add another thread to do progress monitor stuff?

    I assume your concern is about updating JProgressBar's value property from your SwingWorker's thread. Since you're using SwingWorker I assume you know the whole "Swing is not Thread-Safe" drill. If only Sun would specify a few more methods to be thread-safe, like JProgressBar's setValue! After all, isn't the raison d'etre of a progress bar to show how another thread is doing? Oh well, why not use my code, below. You don't need another thread, you only need to access Swing from the EDT, hence my calls to InvokeLater. And in case the progress updates come fast and furious, my code coalesces those events. Enjoy -- Nax.
    class Updater implements Runnable {
         public Updater(JProgressBar jpb) {
              this.jpb = jpb;
         public void run() {
              int v;
              synchronized(this) {
                   queued = false;
                   v = val;
              jpb.setValue(v);
         public void update(int v) {
              boolean go = false;
              synchronized(this) {
                   val = v;
                   if (!queued) {
                        queued = true;
                        go = true;
              if (go)
                   SwingUtilities.invokeLater(this);
         private boolean queued;
         private int val;
         private final JProgressBar jpb;

  • How do I add a progress monitor to a drag and drop question in captivate 7

    I need to build a quiz. We have spent a lot of time on the style guide and appearance but I am having difficulty adding a progress monitor to my drag and drop questions. How can I do this?

    A Drag&Drop is not a normal question slide, hence that progress indicator is not added, and it wouldn't even be functional.
    Long time ago I explained how to create a custom progress indicator, maybe it can help you: Customized Progress Indicator - Captivate blog

  • Displaying progress monitor

    Hi there,
    I'm trying to display a progess monitor as a method runs. The problem is, I have no parent frame (I'm simply looking to display this progress monitor on screen by itself - like a JOptionPane message) However, I can't get anything to display:
    //...method code....
    ProgressMonitor progressMonitor = new ProgressMonitor(null,
                                      "Processing Array",
                                      "", 0, array.length);
           for (int i=0; i<array.length; i++){
           // do some processing on array
           progressMonitor.setProgress(i);
    progressMonitor.setProgress(array.length);
    // ...method continues...Am I trying to do the impossible?

    How to Use Progress Monitor:
    http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html
    Or, maybe the problem is the you need to be using threads:
    http://forum.java.sun.com/thread.jspa?messageID=3375278

  • Progress Monitor OR Progress Bar.........Please help

    I have a JFrame with a menu. As soon as I click the menu I am adding a panel to the JFrame which takes some time. To indicate this to the user should I use the Progress Bar or the progress monitor.
    In either case how do I use it?
    Thanks in advance and it would be very useful if someone could give a small skeleton code.
    Thanks once again

    I am having the same problem which you had with the progress bar.
    I have a DesktopPane with Menu Bar on the top and Internal Frames get added to the DesktoopPane according to the Menu Item selected and the Internal frame takes time to open I want to show the progress bar. I thing you have got the solution by this time.
    Has anybody else have the solution for the above. Basically i want to show the time taken by the classes to load a Internal frame using Progress Bar. Please send me the piece of code. Thanks in Advance.

  • Progressive monitor export

    Saw this thread but didn't exactly answer my question.
    I'm exporting video shot in SD 60i to present on an HDTV (720p). What's the best export? I usually do the "DVD Best Quality 90 minute" with Mpegs and Dolby 2.0. Is there any fine tuning I need to do to make it look the best it can?
    Also, anyone know why broadcast SD content looks really good (detail/quality-wise) on HD sets, while the SD content I shoot looks the same as it does on my computer monitor? I've got a friend with an HD set at home and the local stations have HD channels on the cable network, and their SD stuff (shown on the HD channel) looks better than the regular SD channel. Is it because it's digital cable? Or is it that his set is a TV set (interlaced), not a computer monitor like my HDTV at work (720p)?
    Hope this makes sense.
    Thanks,
    Jonathan

    Just use log=<any filename> on the exp command line.
    The log file can be read by a different session.
    If you want to see progress (and cause a performance hit) use the feedback=
    option.
    You really would learn this a lot faster by reading the documentation instead of asking doc questions over and over again.
    Sybrand Bakker
    Senior Oracle DBA

  • Progress monitoring for long operation

    I know that questions similar to this have been asked many times, but I have not gotten an answer that works for me, so here goes. I have a dialog box with various parameters that the user can specify for a long running task. After the user clicks "OK", I want the dialog box to disappear and instead to have an indeterminate jprogressbar display while the task is running. I have tried using SwingWorker classes and invokeLater(), but I ahve not gotten anything to work. Could someebody please help me out with which parts of the code:
    1. Destroying the old dialog box
    2. Starting the long task
    3. creating the JProgressbar and making it indeterminate
    4. Destroying the JProgressBar
    5. informing the user that the task is complete
    need to be performed using a SwingWorker or invokelater and how the parts should fit together.
    Thank you for the help,
    Jeff

    1. Destroying the old dialog box"old dialog box".dispose();
    3. creating the JProgressbar and making it
    indeterminateBetter create JProgressBar object before starting the thread.
    2. Starting the long task
    4. Destroying the JProgressBar
    5. informing the user that the task is completeIn your class, define the SwingWorker as:
        final SwingWorker worker = new SwingWorker() {
            public Object construct() {
                /* start your long task.
                 * Call local method, method from other
                 * class, whatever.
                return new Object();
            public void finished() {
                /* To finish off the long task.
                 * This method is called when the thread
                 * finishes.
                 * This where you destroy your progress bar
                 * and inform user the task is completed.
        };Of course, you'll need another thread to monitor the progress of your task, and increment the value in progress bar.
    As for indeterminate progress bar, you'll need to know some estimate anyway.
    If at all possible to break the long task in blocks/sections, that number can be applied to the progress bar. Otherwise, get an average performance time, and set the maximum with a figure, and slowly increment the progress bar. If it reaches 99% before finish, then I guess you have to wait till the task ends, then display 100%. If finishes quickly, then you can boost the speed of increment (or instantly display 100%).
    Alternatively, if you can determine (dynamically) how long before the end of task while running your task, you can always update your JProgressBar values (you probably aware of this, anyway).
    Hope this helps.

  • EA3: NullPointerException in progress monitor

    Hi,
    Been getting this quite frequently, but don't know if it's always reproducible the same way.
    The issue is that the progress dialog doesn't refresh, and this exception is logged in the console:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
            at oracle.javatools.dialogs.progress.AbstractProgressMonitor.createDialog(AbstractProgressMonitor.java:358)
            at oracle.javatools.dialogs.progress.AbstractProgressMonitor.mav$createDialog(AbstractProgressMonitor.java:39)
            at oracle.javatools.dialogs.progress.AbstractProgressMonitor$1.run(AbstractProgressMonitor.java:325)
            at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)Hope that helps,
    K.
    (JDK 1.6.0_05)

    OK, you should know what's happening. However, are you sure this is the same?
    Note the exception is fired on createDialog.
    Also, I can see a non-refreshing dialog for at least a few seconds (I imagine until the statement completes).
    Thanks,
    K.

  • Progress Monitor not painting

    I'm working on a program that draws fractals, and I'm using a ProgressMonitor to display the length of the task. The ProgressMonitor is created and updated inside the method that calculates the fractal.
    When I call it the first time in my main method, it shows up, displays properly and disappears. I can do this as many times as I want.
    When I try to call it from the ActionListener associated with my 'recalculate' button the window for the ProgressMonitor appears, but the inside is never painted. After the task is complete it disappears again. Any idea what the problem could be?

    * WaitCursor_Test.java
    import java.awt.*;
    import javax.swing.*;
    public class WaitCursor_Test extends JFrame {
        public WaitCursor_Test() {
            setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            setSize(400,300);
            setLocationRelativeTo(null);
            jPanel.add(jProgressBar);
            getContentPane().add(jPanel);
            setTitle("Wait 10 seconds");
            worker = new SwingWorker() {
                public Object construct() {
                    setCursor(new Cursor(Cursor.WAIT_CURSOR));
                    for( int i=0; i<=100; i++ ){
                        try{Thread.sleep(100);}catch(InterruptedException ex){}
                        jProgressBar.setValue(i);
                    setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                    jProgressBar.setVisible(false);
                    setTitle("Done");
                    return null;
            worker.start();
        public static void main(final String args[]) {
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new WaitCursor_Test().setVisible(true);
         You need to download and compile the "SwingWorker" source code to be able to use it.
         Here it is:
         http://java.sun.com/products/jfc/tsc/articles/threads/src/SwingWorker.java
        private SwingWorker worker ;
        private JProgressBar jProgressBar = new JProgressBar();
        private JPanel jPanel = new JPanel();
    }

Maybe you are looking for

  • How can I export my iTunes lib ray to an SD card

    I'm trying to export songs from library to an SD Card in my VW CC. Is there a good way to do so other than selecting the folders in the finder? Thanks,

  • [Fwd: Re: Mbean method seems to work, but nothing happen]

    Forwarding to security news group for help ... -------- Original Message -------- Subject: Re: Mbean method seems to work, but nothing happen Date: 18 Jun 2004 15:25:51 -0700 From: Claudio Lazo <[email protected]> Reply-To: Claudio Lazo <[email prote

  • Apple TV Sound Quality

    Recently I compared the sound quality of a music track in several ways: 1. Original CD played directly in Bose Lifestyle. 2. Same track stored as AIFF on MacBook streamed with Apple TV with TosLink Cable. 3. Same track stored as AIFF on MacBook strea

  • Can I uninstall Acrobat 9 after upgrading to Acrobat X

    Both versions appear to be on my Mac and I keep getting installer pop-ups for updates to Acrobat 9.

  • Itunes not syncing my music to ios7 devices

    Before I had iOS7 on my iPhone 4, I had all my music saved up and I was a happy person. But when I updated my phone, I could not sync any music into it. I called apple to see if they could help, but no they couldn't because my phone was "too old" so