Need simple progress bar

Hi...
I have a GUI which calls methods in different classes.
There are three long running tasks, which I want to be able to display the progress of.
Each task MUST finish before the other proceeds, so I don't think it is necessary for more than one thread.
I want to have a simple "progress bar" pop-up when each task starts, and then disappear when it is finished. Or, have a "progress indicator" on the GUI, which can be reset and started again.
I have played around with JProgressBars and JProgressMonitors (from this site), but haven't been able to adapt them to the simple needs.
Is there any hope for what I want to achieve?
You would have thought this was an easy task, but I'm a broken man!
Thanks for any help.

Maybe this example will help.
If it does may I claim the duke dollars please
* ProgressDLG.java
* Created on 23 April 2004, 13:38
package com.starjar.tests.progress;
* @author  Peter Henderson
public class ProgressDLG extends javax.swing.JDialog {
    /** Creates new form ProgressDLG */
    public ProgressDLG(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;
        jButton1 = new javax.swing.JButton();
        jProgressBar1 = new javax.swing.JProgressBar();
        jLabel1 = new javax.swing.JLabel();
        getContentPane().setLayout(new java.awt.GridBagLayout());
        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        jButton1.setText("Start");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridy = 5;
        getContentPane().add(jButton1, gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridy = 2;
        getContentPane().add(jProgressBar1, gridBagConstraints);
        jLabel1.setText("jLabel1");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridy = 1;
        getContentPane().add(jLabel1, gridBagConstraints);
        pack();
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        jButton1.setEnabled(false);
        Worker w = new Worker();
        w.start();
    class Worker extends Thread {
        public void run() {
            task1();
            task2();
            task3();
            workerComplete();
        private void workerComplete() {
            try {
                javax.swing.SwingUtilities.invokeAndWait( new Runnable() {
                    public void run() {
                        jButton1.setEnabled(true);
            } catch(Exception e ) {
                // oh well.
        private void setTaskNameFromWorker(final String taskName) {
            try {
                javax.swing.SwingUtilities.invokeAndWait( new Runnable() {
                    public void run() {
                        jLabel1.setText( taskName );
            } catch(Exception e ) {
                // oh well.
        private void setProgressFromWorker(final int progress) {
            try {
                javax.swing.SwingUtilities.invokeAndWait( new Runnable() {
                    public void run() {
                        jProgressBar1.setValue(progress);
            } catch(Exception e ) {
                // oh well.
        private void task1() {
            setTaskNameFromWorker("Running Task ONE");
            for(int i=0; i<100; i++) {
                setProgressFromWorker(i);
                try{ Thread.currentThread().sleep(25); } catch(Exception e) {}
        private void task2() {
            setTaskNameFromWorker("Running Task TWO");
            for(int i=0; i<100; i++) {
                setProgressFromWorker(i);
                try{ Thread.currentThread().sleep(25); } catch(Exception e) {}
        private void task3() {
            setTaskNameFromWorker("Running Task THREE");
            for(int i=0; i<100; i++) {
                setProgressFromWorker(i);
                try{ Thread.currentThread().sleep(25); } catch(Exception e) {}
     * @param args the command line arguments
    public static void main(String args[]) {
        new ProgressDLG(new javax.swing.JFrame(), true).show();
    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JProgressBar jProgressBar1;
    // End of variables declaration
}Peter Henderson
Sales Manager
Starjar Ltd
http://www.starjar.com

Similar Messages

  • Need very simple ''progress bar'' or a ''Please wait notice'' in javascript

    I have a JSF portlet app, made in JSC. It uses remote EJB calls and some calls take a long time to finish. E.g. User clicks a button, some data are gathered, sent to an EJB and the app. is waiting for reply.
    For the user it looks like this: Click ... Internet Explorer progress bar flashes, nothing happens for 30s, then the progress bar starts from zero again and loads the next page in 15s.
    So I need a very simple notice in the middle of the screen, that will just say "Take a break, don't click the button again, please! ... " and animate a clock, a bar or whatever, maybe disabling the window so the user will not be able to push buttons. (The users are annoying folk!)
    The message should dissapear as soon as the next (or the same) page loads.
    I've never did javascript, so if anybody has a simple example code, I will be grateful and give him a duke or two. (And I really don't need the AJAX super-components)

    Martin, best of luck, i fought this same problem last year.
    Even when I got a progress bar on my page, it would not "animate" as IE apparently does not animate gifs after a form is submitted (and before the page is destroyed). I think I eventually got around this by adding an onclick event to my form submit that reset the image.
    Best of luck.
    Ideally, is there anyway that we can get this IE behavior (page loads, waits for X times, page loads again correctly) fixed? This is highly confusing to my clients.

  • Progress Bar Widget

    Hi.
    I'm looking for a simple progress bar (a.k.a ticker) widget and wondering if anyone knows of one that might exist.
    Everything I see is for a specific purpose - none that match my need.
    I am looking for something more universal, where I can set the starting value, goal value and then manually change the current value and the meter displays the 'progress' with a solid bar on a scale.
    A common assimilation would be to the "thermometer" a charity may use to illustration how much money they've raised relative to what the ultimate goal is.
    The Nike widget is the closest visually to what I am looking for - but of course it has a very specific application. I need something that will let me set my own unit of measure - be it weight or currency or whatever.
    There are tickers that you can build on the internet for using on a website. Does anyone know if something like this exists for the Dashboard?
    Thx.

    I'm not sure I understand what you mean.
    Take a countdown widget by example.
    It assumes starting date is TODAY.
    I can assign an ending date.
    It calculates how many days are left and displays that.
    For a progress bar, I would imagine this would be even more simple.
    For example, I want to track progress of a fund raising.
    There is a field where I specify starting amount = 0
    A field where I specify what the goal amount is = 100
    A field to specify unit value being measured (weight, currency or days - for example)
    And a field where I enter the "current amount" - for example 25.
    The widget simply displays a solid bar within the scale proportionate to the amount I've entered as the current value.
    This requires code - I understand that. But I don't see why this can't be done - and am quite surprise that I haven't been able to find an existing widget that already does this. I'm not really wanting to learn the API for creating my own widget if I can help it.

  • Global Variable in Progress Bar

    I have an existing labview code that is comprised of a main vi, which is the user GUI, and several (approx 70) sub vi's. I am trying to add a progress bar to the front screen (User GUI) that will immediately increment after it hits certain sections of code. I am doing this using a global variable to store the value of the current progress, and then attempting to write to the progress bar on the main screen after each incrementation. Is there a way to link the value of the main progress bar to the global variable so that it updates as soon as the value is incremented? The problem I am facing is that when I update the global variable in a subvi, the progress bar takes the value of the subvi after it is completed, skipping all the numbers in between. I realize this is because I am not correctly writing to the progress bar, but I am unsure how to do so. If this isn't a good method, does anyone have any suggestions?  
    For Example:
    Main Vi           SubVi1        SubVi2
    (1-4)                (5-8)             (8-12)
    Progress Bar: 1 2 3 4 8 12
    (I did try the Progress Bar Library NI provides, but I need a progress bar on the Front Panel, not a pop up, so I can debug while the code runs)
    Thanks- Adam
    Solved!
    Go to Solution.

    I'd go with a Action Engine to update the progress bar VIA vi server referance.  Here's an example using a AE I have for just this type of progress bar.
    If you haven't read Ben action engine nugget, it should be required, you can find it here
    By constructing a "resource module" (a special AE that holds a referance to the resource to act on)  after initializint the AE you can call any "method" on the resorce from any location in the application instance.  These babys really let you do some interesting things to the GUI from wherever the real actions is taking place.
    Jeff
    Attachments:
    Ex AE Slider.vi ‏15 KB
    Progress.vi ‏26 KB
    Progress Meth.ctl ‏11 KB

  • Switch to install with progress bar ONLY!

    I have successfully installed Photoshop CS3 onto Windows XP SP2. However, I do not want my install to be completely silent: I want to see a progress bar.
    For silent install I use the following switch: setup.exe --mode=silent
    The next line in cmd says"UI:Silent"
    If I use no switches (only type in setup.exe), the next line in cmd is: "UI:Full" Also, "setup.exe --mode=gui" will initiate "UI:Full".
    What are other install switches? I want a silent install with a progress bar only.

    We too are in the same boat, we need a progress bar so that our users know that we are deploying the application.
    I've tried various random switch for the "UI mode" but none work. There must be others than silent or Full.

  • CS3 install silent with progress bar ??

    Is it possible to install full CS3 with progress bar showing when the program silently installs?
    Install works fine using UI mode Silent and Full, but I can't find andy other options?
    My problem is when using the silent install of full CS3, shortcuts are available before the installation is finished. Since the installation takes time, users may click the shortcut before the installation is finished, resulting installation fails.
    Using the UI Mode Full is dependent on the users, and not accepted by company.
    -Odesti

    We too are in the same boat, we need a progress bar so that our users know that we are deploying the application.
    I've tried various random switch for the "UI mode" but none work. There must be others than silent or Full.
    Phil H

  • Progress bar to update as script runs

    Hi, I'd like to have a progress bar being displayed as my script runs. I created a simple progress bar as follows:
    var win = new Window("palette", "SnpCreateProgressBar", [150, 150, 600, 260]);
    win.pnl = win.add("panel", [10, 10, 440, 100], "Script Progress");
    win.pnl.progBar = win.pnl.add("progressbar", [20, 35, 410, 60], 0, 100);
    win.pnl.progBarLabel = win.pnl.add("statictext", [20, 20, 320, 35], "0%");
    win.show();
                        while(win.pnl.progBar.value < win.pnl.progBar.maxvalue)
                                  // this is what causes the progress bar increase its progress
                                  win.pnl.progBar.value++;
                win.pnl.progBarLabel.text = win.pnl.progBar.value+"%";
                                  $.sleep(10);
        alert('Done!');
    win.close();
    Now, if I target the ExtendScript Toolkit, I can see the "animation" of the bar progressing. But If I target illustrator, I only see when it's at 0% and then it jump to 100%. Is there a way to update the information visually as the script progresses?
    Thanks!
    I'm running CS6 on mac.

    Hi,
    i was using the above code in my application but it is displaying the following message when i run it:
    Can you please help me out.
    Thanks
    Harsh    

  • Survey progress bar

    HI,
    Sharepoint 2013 survey with paging (page break questions) .
    I need a progress bar, I can see posts about using the task %complete field to generate a client side progress bar
    but ther's no such field in a Survey List.
    Whats my options ?
    Thanks

    Hi,
    According to your post, my understanding is that you wanted to add a progress bar in survey list.
    There is a progress bar tool in CodePlex, you can install it, and upgrade to check whether it achieve your scenario.
    http://mossprogressbar.codeplex.com/
    We can also use the SharePoint Designer or code to achieve it, the following article contains 5 ways to create progress bar in SharePoint, you can have a look at it.
    http://blog.pentalogic.net/2011/05/how-to-create-progress-bar-in-sharepoint/
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • Deploy Libraries VI with the progress bar

    When I right-click>deploy all a vi pops up that displays a progress bar while the shared variables are being deployed. However, if I use the Deploy Libraries VI from the DSC module I do not get a progress bar.
    I really need a progress bar. I have a huge number of SV's and really want my users to know that the system is actually doing something during the long wait.
    Thanks in advance.
    PaulG.
    "I enjoy talking to you. Your mind appeals to me. It resembles my own mind except that you happen to be insane." -- George Orwell

    Hi Paul,
    I have not tried it, but you might be able to use the 'Commit Shared Variables' vi to manually deploy each variable to the SVE.  This way you could easily loop through the libraries and
    display a running list of variables or a progress bar.  I am not sure if the SVE will automatically create a process for you or if that is something you will also have to do with another DSC
    vi that is available for that purpose.

  • Show Progress Bar while Accessing data from Server

    Hi,
    I need a Progress bar to be displayed when my application triggers database to backup, As the data would be large progress bar makes sense to display the time span.
    I need a progress bar in place to show the progress of the task,
    Can anyone suggest me how to do this? This should be shown when i backup my database from WPF.
    I have code written for server side and just need a progress bar and timer.
    Thanks,
    Shreyas M

    You could use a BackgroundWorker. There is a complete code sample available on MSDN here:
    https://msdn.microsoft.com/en-us/library/cc221403(v=vs.95).aspx. You do the long-running work, i.e. the actual backup, in the DoWork event handler.
    Note that you will need to report the progress (by calling the ReportProgress method of the BackgroundWorker) and calculate the total time it will take to complete the backup operation yourself.
    It might be easier to just display some "waiting" element and no progress bar during the time it takes for the operation to complete:
    <!-- replace this with any element like for example an Image -->
    <TextBlock x:Name="loadingElement" Visibility="Collapsed">please wait...</TextBlock>
    loadingElement.Visibility = System.Windows.Visibility.Visible;
    System.Threading.Tasks.Task.Factory.StartNew(() =>
    //call your backup method here (this code is being run on a background thread....
    .ContinueWith((t) =>
    loadingElement.Visibility = System.Windows.Visibility.Collapsed;
    }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext());
    After all you probably don't know how long time it will take for the method to complete, right? If you want to display a ProgressBar, the backup method should report the progress somehow. If you just call a method and wait for it to complete, you have no
    idea of how long time it will take for the method to return. You will then have to estimate the actual time and then increase the value of the progress bar accordingly.
    There is no way to find out before hand exactly how long time it will take until a method returns so it is the responsibility of the (backup) method to report to the caller how long time it needs and how long time is left until it is done. Far from all API:s
    support reporting progress.
    As you see in the BackgroundWorker example on MSDN, you could call the ReportProgress once in each iteration of a loop but if there is no loop in your Backup method you better just display a busy indicator without a progress bar since you don't know anything
    about the progress anyway.
    Edit: You could of course also display a ProgressBar element with its IsIndeterminate set to True. Just replace the TextBlock and use the sample code above:
    <ProgressBar x:Name="loadingElement" IsIndeterminate="True" Height="50"/>
    Setting this property to true is useful when you don't know how long time the operation will take: 
    https://msdn.microsoft.com/en-us/library/system.windows.controls.progressbar.isindeterminate(v=vs.110).aspx
    Hope that helps.
    Please remember to mark helpful posts as answer to close your threads and then start a new thread if you have a new question. Please don't ask several questions in the same thread.

  • Progress bar with install screen.

    Hi all,
    On my app I need a progress bar when I the app install some RMS records. Because of the app has near a milliom of records, this install is so longer, and I t's better show the progress of it with an bar :).
    How it's possible do it?
    Kind regards.

    In such case i recomend writing your own LoadingCanvas or something like that (You draw a kind of rectangle which size is connected to current progress). Animating this canvas while conducting another task is a different issue. In my soft I needed to view a progress bar while downloading images and so on from net. I achived it by running one separete thread for the connection and lunching a timerTask for the canvas redraw events. In my case it worked fine almost on every device but ned Nokia E series phones had some problems in memory management of 2 paralel task so i had to remove this form my app becouse it caused instability of application.
    Regards
    mchmiel

  • Update progress bar from repeater events

    I have a component that uses a repeater to download and set information on a collection of items from the internet.  This can take a while, so I tried to set up a panel with a progress bar to provide some feedback.
    Problem is, when the repeater is executing, it apparently doesn't yield time so the progress bar can update. (?!)
    The end result is that the progressbar doesn't show anything until the repeater is done, at which point it shows the last value the repeater loaded.
    So, is there a way to get around this?  Can the repeater be triggered with timer ticks, instead of blindly looping?
    Scouring the docs, but nothing is showing, yet.  At worst case, I guess I can bag the repeater and just fetch the items in a timer driven loop, rather than use the repeater mechanism.  Would be a drag, but I need the progress bar to update.
    Any thoughts appreciated.
    rickb

    Changing to window made no difference.
    One solution is to show the document being built, now its hidden. Another would be to show the progress in a palette.
    I have never built a palette, is it possible to have a swf-file that triggers javascript?
    Is it possible to add buttons to the palette menu on the top right?
    But solving this would be the easiest...

  • Would someoen show me example of progress bar?

    i am confused by Sun's explanation... i just wanna make a simple progress bar thats sorta like a timer.... you get a number, say 100, and the progress bar will show the progress of a thread counting to that number in seconds...

    ugly Q&D,
    import java.awt.*;
    import javax.swing.*;
    public class ProgressBar
          private static JFrame f = null;
          public PPanel p = null;
          private int min = 0;
          private int max = 100;
          private int now = 0;
          private int count = -1;
          private long sleepTime = 500;
          private Thread clockThread = null;
          private volatile boolean noStopRequested = true;
          private Runnable r = null;
          private class PPanel extends JPanel
             public void repaint()
                Graphics g = getGraphics();
                if( null == g ) return;
                g.setColor( Color.cyan );
                double d = ( (double) now / (double) max ) * getWidth();
                g.fillRect( 0, 0, (int) d, getHeight() );
          public ProgressBar()
          public void setNow( int i )
          this.now = i;
          p.repaint();
          private void initialize()
          p = new PPanel();
          p.setPreferredSize( new Dimension( 100, 10 ) );
          try
             r = new Runnable()
                   public void run()
                   try
                      runWork();
                   catch( Exception e )
                      e.printStackTrace();
                      //error
          catch( Exception  e )
             e.printStackTrace();
          clockThread = new Thread( r );
          clockThread.start();
          public static void main( String[] args )
          ProgressBar pg = new ProgressBar();
          pg.initialize();
          f = new JFrame();
          JPanel pp = (JPanel) f.getContentPane();
          pp.add( pg.p );//bad
          f.pack();
          f.show();
          private void runWork() {
          while( noStopRequested ) {
             try {
                this.process();
                Thread.sleep( sleepTime );
             } catch( Exception e ) {
                //error
                e.printStackTrace();
          private void process()
          setNow( count++ );
          if( count == max )
             f.dispose();
          public void stopRequest()
          noStopRequested = false;
          clockThread.interrupt();
          public void startRequest()
          noStopRequested = true;
          clockThread.interrupt();
    }

  • Help needed please, with Iphone stuck with apple picture and progress bar after software update attempted

    Help needed please, everytime I try to update the software version on my iphone it comes up with a message saying it could not be completed and is now frozen with the apple picture and progress bar on it. Do I unplug it and hope the macbook pro sees it again, I also stupidly did not back up before starting the download which I realise I will have to go back to the previous back up. This keeps happening, everytime I do this type of update, I'm starting to think I should just give up on updating my software on the Iphone. I thought it was happening because I was using a window based computer to do the updates, this time I used my Macbook Pro. Please somebody help

    ljm17 wrote:
    ...This keeps happening, everytime I do this type of update, I...
    Then you should know what you need to do... If you don't remember...
    See Here  >  http://support.apple.com/kb/HT1808

  • HT1212 My ipad mini has been crashing a lot recently so I started a system reset. However, it's now stuck with the progress bar less than a quarter gone: this has been the case for several days now. I have tried resetting from itunes but it needs the pass

    Now it's stuck with the progress bar less than a quarter full. I have also tried resetting through itunes which works right up to the point where itunes states that it needs the passcode to be inputted into the ipad to connect to it. At which point it then sticks at the same progress bar point. HELP!! please, this ipad is really important to my work.

    Well the term "hotlined" I have never heard before. In any case many states (like NY) just passed regulatory powers to the State Public Service Commission of which it may be called something different in your state. You could file a complaint with them. Or file a complaint with your state attorney generals office, they also take on wireless providers.
    The problem here is the staff you speak to are poorly trained, in days gone by it took one call to them and they pulled up your account and see the error and had the authority to remove any errors. They did not remove legitimate account actions, but used their heads instead of putting a customer off or worse lying to the customer.
    Its a shame you have to go through what you going through.
    Good Luck

Maybe you are looking for