Results 1 to 4 of 4
  1. #1
    myka is offline Member
    Join Date
    Mar 2010
    Posts
    10
    Rep Power
    0

    Post Java Progress bar

    Hi,
    I need to create a progress bar without using a thread. Main reason for this is I already finished doing my project and adding a thread will change everything.So I have this method xyz() and this method process for 1-3 minutes depending on the task. If it is a small task the results are very fast, but if it is a complex task then the user will think the programm is stuck. But after a while(2-3 min) it will return accurate results so i need to add a progress bar for this time consuming method...

    So please tell me the easiest way to do that and i am ok with a normal progress bar.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Despite your restrictions, I'd recommend that you use a background Thread if you don't want your GUI to grind to a halt. A SwingWorker would work nicely here (if you are using Java 1.6).

    Much luck.

  3. #3
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,233
    Rep Power
    7

    Default

    Whats with the large font?

    I already finished doing my project and adding a thread will change everything.
    It won't change everything. If your code is written in a proper well structured and organized manner then it will be simple to change.

    Its better to learn how to do things correctly then spend time working on "hacks". Long running tasks should execute in a Thread so you don't block the GUI from repainting. I suggest you read the API and follow the link to the Swing tutorial on "How to Use Progress Bars" for a working example.

    Edit:

    I see we know have 2 votes for doing it the proper way. I better work on my typing skills if I'm going to beat Fubarable to the punch!
    Last edited by camickr; 05-08-2010 at 07:10 PM.

  4. #4
    myka is offline Member
    Join Date
    Mar 2010
    Posts
    10
    Rep Power
    0

Similar Threads

  1. problem on progress bar
    By ravidasineni in forum AWT / Swing
    Replies: 2
    Last Post: 12-27-2009, 02:23 AM
  2. progress bar problem
    By LeonLanford in forum New To Java
    Replies: 2
    Last Post: 10-21-2009, 04:14 PM
  3. How to use Progress bar
    By LankanSniper in forum AWT / Swing
    Replies: 3
    Last Post: 03-25-2009, 10:44 AM
  4. Console Progress Bar
    By new_2_java in forum New To Java
    Replies: 1
    Last Post: 02-16-2008, 02:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •