Threaded Progress bar wont restart

I know that if i have a progress bar on a form and i wont it to increment on a button click, i must thread it so i did this
the Main class is "class Form" with variables
public static JProgressBar progress;
ThreadedProgress threadbar = new ThreadedProgress();
public void actionPerformed(ActionEvent e)
if (e.getActionCommand() == "Submit")
threadbar.start();
in the same file i made the a theard to increment the progress bar
class ThreadedProgress extends Thread
     int num = 0;
     ThreadedProgress()
          //setDaemon(true);
public void run ()
num = 0;
Form.progress.setValue(0); // progress bar in "class Form"
while (num <1001)
Form.progress.setValue(num);
try
Thread.sleep(10);
catch (InterruptedException e)
     JOptionPane.showMessageDialog(null,e);
num += 10;
if(num > 1001)
JOptionPane.showMessageDialog(null,"MessageSent");           
When i click the "Submit" button once to increment the progress bar with the thread it works fine but when i click it a 2nd time, nothing happens...

Probably the easiest thing to do is to make an anonymous inner Thread class that is within your actionPerformed(ActionEvent e) method. This was a new Thread class could be made each time the button is clicked.
I gather that from your code, after a message has been sent, you want to show progress for a second. With Java 1.4 - it is possible to put the progress bar in indeterminate mode:
progressBar.setIndeterminate(true);  // starts progress bar animation
progressBar.setIndeterminate(false); // stops progress bar animationhttp://java.sun.com/docs/books/tutorial/uiswing/components/progress.html
When you start sending your message, you could start the animation, and stop animation when the message is sent. You can reuse this method numerous time, as Java makes the required threads, etc. internally.
Good Luck!

Similar Messages

  • I just bought the darkness and the progress bar wont fill up, i just bought the darkness and the progress bar wont fill up

    i just bought the darkness and the progress bar wont fill up, i just bought the darkness and the progress bar wont fill up....help

    Hi..
    Not sure what, "progress bar" you are referring to. Did you mean that the app isn't completely downloading??
    Try contacting the app's developer here >  http://support.2k.com/anonymous_requests/new

  • OS hangs at loading progress bar when restarting after Security Update

    I've searched for other people who have had issues with the Security Update, but my issue doesn't seem to have been solved. Here's the story:
    Just installed the new Security update. Shut the computer down for the night, started it up, and halfway through starting up it restarted itself again. It got past the grey Apple, the blue progress bar started loading, got to the end, but doesn't go anywhere. I've let it sit for 15 minutes, but no progress. The internal fan sounds like an airplane taking off, it just keeps going faster and nothing happens. Tried rebooting in safe mode, but it got hung up on the grey Apple and spinning wheel of death.
    Anything I can do from the Terminal to fix this?
    Thanks guys!

    cPants:
    Welcome to Apple Discussions.
    Have your tried:
    Repair Disk
    Insert Installer disk and Restart, holding down the "C" key until grey Apple appears.
    Go to Installer menu (Panther and earlier) or Utilities menu (Tiger) and launch Disk Utility.
    Select your HDD (manufacturer ID) in the left panel.
    Select First Aid in the Main panel.
    (Check S.M.A.R.T Status of HDD at the bottom of right panel, and report if it says anything but Verified)
    Click Repair Disk on the bottom right.
    If DU reports disk does not need repairs quit DU and restart.
    If DU reports errors Repair again and again until DU reports disk is repaired.
    If DU reports errors it cannot repair you will need to use a utility like Tech Tool Pro or Disk Warrior
    Good luck.
    cornelius

  • Macbook Pro seems to be bricked by ML install. Upon restart it shows a progress bar which makes it to about 15%, and then the machine simply shuts off. Help?

    Title pretty much says it all. Install seemed to be going fine, then upon restart it hit a gray screen with a progress bar for about 30 seconds. Once the progress bar makes it to about 15% the machine simply shut off. I tried turning the machine on again a few times, but each time I had the same issue. I then tried running the 10.8 recovery disk, but it just showed the gray spinning wheel for about 6 hours. Any ideas?

    Something similar issue with me too. Intallation went fine. Then it started updating java once reboot it got stuck on grey screen. It wont boot at all. That spinning wheel keeps on going forever. :(

  • Problem installating Snow Leopard on old Macbook Pro with Intel Core 2 Duo. After creating partition on internal hard disk (Extended Journaled), installation starts but stops at half of the progress bar. Screen asking Restart appears.

    Hello:
    I have tried installing Snow Leopard via the installation disc on a Macbook Pro (2007) with an Intel Core 2 Duo, but I the installation has failed more than 5 times.
    I have first formatted and partitioned the internal hard disk with Mac Os Extended Journal format.
    Once the installation starts, it starts without a problem unti lthe progress bar gest until half completed then a screen asking for a Computer Restart shows up.
    It asks to press the power button for some time until it the computer shuts down and then, press again to turn it on.
    Once turned on, the installation disc gets readed, the installation screen appears again and asks again to start the whole installation process form the beginning.

    Then you have a Hardware Problem.
    Your system is Crashing part way through the install and Re-Booting because of the crash.
    Could be the drive itself or it could be some other hardware part in your system. Like the RAM.
    To check if it is the internal drive connect an External drive to the system by USB and do the install on that external. If the install completes then it more then likely the drive is bad. If it crashes again then it is more then likely some other piece of hardware in your system.

  • After prompted to update 10.9.1, my MacBook Pro updates and went thru restart but failed...I tried to start my book and gray screen, Apple logo both on, chime sounded, then went to progress bar, less than half macbook shuts down...did few times, same!!

    After prompted to update 10.9.1, my MacBook Pro updates and went thru restart but failed...I tried to start my book and gray screen, Apple logo both on, chime sounded, then went to progress bar, less than half macbook shuts down...did few times, same!!
    Go to system repair, there is a prompt that cannot repair live etc....I don understand!!! Help, I need the book for work tomorrow!!

    Thanks clintonfrombirmingham...
    After clicking "repair disk" it says DISK UTILITY STOPPED REPAIRING MACINTOSH HD, DISK UTILITY CAN't REPAIR THIS DISK. BACK UO AS MANY OF YOUR FILES AS POSSIBLE, REFORMAT THE DISK, AND RESTORE YOUR BACKED -UP FILES....
    written in red: ERROR: DISK UTILITY CAN'T REPAIR THIS DISK,,,DISK, AND RESTORE YOUR BACKED-UP FILES.
    how can I back up when I cannot even start my macbook? I am stuck here and have lots of important files in the hd... Please help me? Thanks you!

  • Yosemite keeps installing (progress bar) after every restart

    I've recently installed Yosemite and there are currently no more updates available. However every time I restart or reboot my computer I continue to see an install progress bar as if the OS is finishing up an install. Since this is happening every time I reboot or restart my computer I'm thinking something might have gone wrong with the install.
    Any suggestions as to what this anomaly might be? t

    Per PeterVL57 the progress bar is underneath the apple-logo and this process is identical on my two iMacs and MacBooks. Thanks everyone for the quick replies. I guess I was so accustomed to identifying the progress bar with software installs, it hadn't occurred to me that they'd use the same approach to the initial loading of the OS X.
    Thanks again everyone:-)
    All the best.

  • How to start and stop a progress-bar thread before/after the main thread

    hi. I would appreciate any kind of help on my request.
    I have this as my main() function
         public static void main(String[] args)
              SwingUtilities.invokeLater(new Runnable(){
                   public void run(){                              
                        Options op = new Options();
                        OdessaClient oc = new OdessaClient(op);     
                        oc.setVisible(true);                    
         }Whenever I try to start a simple JFrame with an indeterminate progress bar on it just before the main function and stop it somewhere after I get a StackOverFlow error
    Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
         at java.awt.Component.show(Component.java:1302)
         at java.awt.Component.setVisible(Component.java:1253)
         at com.client.CylonBar.hide(CylonBar.java:25)
         at java.awt.Component.show(Component.java:1302)
         at java.awt.Component.setVisible(Component.java:1253)
    ...and so on...How must I implement something like it?

    Not precisely that way, but just off the top of my head, you would have to have a handle to the proccess (server) in the first window, then have a monitor program that allows you take this handle and end it. I would make this monitor program be the gateway to starting and stopping your server. To run a .bat file you can use runtime.exec().

  • How to use thread only for progress bar.....

    Hello,
    I am working on an application which is taking time to load. Now I want to use a progress bar to tell the user of the application that It is taking time to load. How to do it... I read the Java swing tutorial and went through the example. Please tell me what to do. Because I am unfamiliar with Threads and I am not using thread anywhere in my application.

    You are using threads. All Java execution occurs on threads. Write a Java GUI and you're in a multithreaded environment - there's no way out of that.
    If your "application is a complex one" then you would be better advised to understand threads than to try and pretend that they don't exist. For a start, if you don't think you're using threads then you're destined to run in to all sorts of problems as regards an unresponsive GUI, as you're probably now finding out.

  • Progress bars and threads...

    Hey...
    I've had many replies on my previous questions about progress bars. I thank everybody who was concerned. But i still don't know if i have to use a seperate thread to run the progress of my bar... Can i have a progress bar in a Frame updating the progress of some file loading without having it in a seperate thread ?? I mean if i have an application that runs a Frame, this frame has buttons, textfields and other stuff, one of the buttons uploads a file chosen to a server. Now i also have a progress bar, can it keep progress of the upload without having it in a seperate thread ?? If yes, then how. Cause i can't seem to make it move unless the upload is done... I also want to know that, if i have to use a seperate thread, do i have to use something called a SwingWorker ???

    Here's the deal....
    If you don't use a separate thread, then your file upload process will block the main ("dispatch") thread until it has finished. This means that the GUI will not be updated to show your ever-growing progress bar. You'll see the bar start at zero, and then nothing will happen until the file finishes uploading, and then the bar will show 100%.
    Even if you are updating the bar in a loop, changes will still not be displayed, because repaint requests get put on a queue, and they are executed only when the VM decides it has time to do them (ie when it's finished doing your file upload!)
    So, yes you do need to use a thread to load your file and change your progress bar. and if that thread will update any GUI elements directly, start it by calling SwingUtilities.invokeLater(myThread). Also, make sure you do "myThread.setPriority(3);" (or thereabouts - make sure it's less than 5) on the thread before invoking it. This way, the main thread that updates the gui will have priority, so will update regularly.

  • Installing adobe reader update, install progress bar stops at 30% and never restarts. [was: Downloading]

    Installing adobe reader update, install progress bar stops at 30% and never restarts.  IMAC yosemite 10.10.1

    Not sure if you mean installation or download, but here are some links to look at
    Quick fix | Install, download | Reader
    Install Adobe Reader X | Mac OS
    Troubleshoot Adobe Reader installation | Mac OS

  • When my Mac battery dies and I turn it back on, it always crashes on the grey screen with the progress bar, then it restarts (taking forever) and does not remember any of the programs I was running. MacBook Pro 13 inch running Mavericks

    When my Mac battery dies and I turn it back on, it always crashes on the grey screen with the progress bar, then it restarts (taking forever) and does not remember any of the programs I was running. MacBook Pro 13 inch running Mavericks

    http://osxdaily.com/2014/10/17/os-x-yosemite-installation-stuck/
    also use the Command-L to view logs during installation

  • Yosemite Restart Stuck At Progress Bar

    Okay so I installed Yosemite yesterday, and it was working well until my mac suddenly froze in black screen, so I had to force shut down by pressing the power button for 10 seconds.I restarted my mac, and now it's stuck on the booting screen (apple logo and a progress bar), I tried force restarting multiple times, but the progress bar always gets stuck at 50%. Please help!

    Try rebooting into safe mode http://support.apple.com/kb/HT1564?viewlocale=en_US
    Verify disk and file permissions using Disk Utility and then reboot normally. 

  • I tried to update the software overnight, and it was still in the beginning stages of the progress bar when I woke up.  When I restarted the process I have to restore the phone, its again stuck in the beginning of the process. Does anyone know how long th

    I tried to update the software overnight, and it was still in the beginning stages of the progress bar when I woke up.  When I restarted the process I have to restore the phone, its again stuck in the beginning of the process. Does anyone know how long this should take?  The beginning sections seemed to fly by.

    Hi NWL1,
    Thanks for the question. If I understand correctly, the iPhone won't update and is stuck. I would recommend that you read this article, it may be able to help you resolve or isolate the issue.
    If you can't update or restore your iPhone, iPad, or iPod touch - Apple Support
    Thanks for using Apple Support Communities.
    Have a great day,
    Mario

  • Need help with Threading GUI progress bar

    Anyone able to help? I'm sure you've seen this a million times. I've google'd around and tried examples but still can't get a progress bar to work properly under the following situation:
    1. Created a panel with several components to select directory, display directory in tree etc.
    2. When a specific button (Search) is clicked, I want a secondary window to popup and report progress of searching down the directory.
    As you'll probably guess, the progress window isn't being updated until the end. I'm using Threads and using InvokeLater but nothing happens. Is there any good example that does the above? I can't seem to find one to figure this out.
    Thanks
    Speedy.
    Sample code:
    main.java:
    ========
    public class Main {
    public static void main(String[] args) {
    MainPanel mainPanel = new MainPanel();
    mainPanel.show();
    MainPanel.java:
    ============
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    public class MainPanel extends JFrame implements ActionListener {
    public MainPanel() {
    this.setSize(100,100);
    JButton startButton = new JButton("Start");
    this.getContentPane().add(startButton);
    startButton.addActionListener(this);
    public void actionPerformed(ActionEvent event) {
    ProgressPanel pp = new ProgressPanel();
    pp.show();
    SimpleTask st = new SimpleTask(pp);
    st.start();
    while (st.isAlive()) {
    System.err.println("waiting..");
    try {
    Thread.sleep(100);
    } catch (Exception e) {};
    System.err.println("finished!");
    SimpleTask.java:
    =============
    import javax.swing.SwingUtilities;
    public class SimpleTask extends Thread {
    ProgressPanel pp = null;
    public SimpleTask(ProgressPanel _pp) {
    pp = _pp;
    this.setDaemon(true);
    int i = 0;
    String position = "";
    public void run() {
    Runnable updateGUI = new Runnable() {
    public void run() {
    pp.setText(position);
    try {
    for (i=0; i<50; i++) {
    position = "Now on = " + new Integer(i).toString();
    System.err.println(position);
    SwingUtilities.invokeLater(updateGUI);
    sleep(100);
    } catch (Exception e) {}
    ProgressPanel.java:
    ===============
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    public class ProgressPanel extends JFrame {
    private JLabel label = new JLabel();
    public ProgressPanel() {
    this.setSize(200,200);
    this.setLocation(100,100);
    this.getContentPane().add(label);
    setText("Start");
    public void setText(String text) {
    label.setText(text);
    }

    Ok, I'll look down that road. I should have said the Thread is being used because the current while loop will be changed to perform real work. Just an example at the moment to show what I'm trying to do. Does this make a difference? The real task will be to drill down directories, counting file types/dirs etc...

Maybe you are looking for

  • How do I know how many bytes it has read so far ?

    Like in a FileInputStream.read(byte [] b) method. How do I know how many bytes have been read into b so far ? Thanks!

  • Ledger Balance entry

    Hello Friends, After shifting over form the legacy system to SAP during the mid of the year, under which screen ( TI code ) do we post the past months balances ( within the same Fiscal Year ).  Note that I have to post only the monthly balances and n

  • How to solve the problem of my itunes does not support the purchase of the apps ..?

    hai plzz help me

  • Help!  Install/Uninstall Issue

    My granddaughter installed a new IPOD Nano on my HP Pavilion 552w about 2 weeks ago. Initial installation went OK and she downloaded tunes. Since the installation, my PC has stalled at shutdown. So...I tried to uninstall and reinstall the Nano. Upon

  • Concerning privacy, and trust

    I've been using the last "good" version of skype (i prefer older versions a bit more) for a long while now, and I find it rather disturbing that I'm forced to update. Why does skype keep doing this? Every update skype has, makes it less enjoyable. Sh