Results 1 to 7 of 7
  1. #1
    akssingh400 is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Default Problem With JProgressBar

    I m having some problem with JProgressBar.. :(
    i think their is some thing wrong with my code
    on a button click i want my to set my progressbar to indeterminate mode and send a mail. But i can't see any change to the progressbar.

    //// code for button click


    jProgressBar.setIndeterminate(true);
    Pattern splitter = Pattern.compile(",");
    String[] ToAddress = splitter.split(jTextPane2.getText());

    InternetAddress[] addressTo = new InternetAddress[ToAddress.length];

    try {

    for (int i = 0; i < ToAddress.length; i++)
    {
    addressTo[i] = new InternetAddress(ToAddress[i]);
    }
    message.setFrom(new InternetAddress(AddressFrom));
    message.setRecipients(RecipientType.TO, addressTo);
    message.setSubject(jTextField1.getText());
    message.setText(TextPaneMessage.getText());

    Transport.send(message);

    } catch (MessagingException el) {
    System.out.println(el);
    }
    System.out.print("done");
    jProgressBar.setIndeterminate(false);

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,963
    Rep Power
    8

    Default

    That's because you're doing all of this code on the EDT. The JProgressBar is also updated on the EDT (all of the GUI is). So the JProgressBar won't be updated or repainted until this method exits- and by then, you've deactivated indeterminate mode.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    akssingh400 is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Default

    Thank you very much sir... :)
    so should i go for SwingWorker? :)

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,963
    Rep Power
    8

    Default

    Quote Originally Posted by akssingh400 View Post
    Thank you very much sir... :)
    so should i go for SwingWorker? :)
    What happened when you tried it?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    akssingh400 is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Default

    Quote Originally Posted by KevinWorkman View Post
    What happened when you tried it?
    haven't tried yet sir will do it tomorrow and will reply to :)

  6. #6
    akssingh400 is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Default

    Quote Originally Posted by KevinWorkman View Post
    What happened when you tried it?
    i just thought of giving it a try before going to bed.
    And it did work :)

  7. #7
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,963
    Rep Power
    8

    Default

    Quote Originally Posted by akssingh400 View Post
    i just thought of giving it a try before going to bed.
    And it did work :)
    Cool. I'm glad you got it working.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Load thread with JProgressBar
    By Dennis in forum Advanced Java
    Replies: 10
    Last Post: 10-09-2010, 09:32 AM
  2. JprogressBar
    By cotarelo in forum AWT / Swing
    Replies: 7
    Last Post: 03-26-2010, 03:13 AM
  3. JProgressBar inside a JDialog
    By Mikey_S in forum AWT / Swing
    Replies: 10
    Last Post: 07-13-2009, 02:55 PM
  4. Updating a JProgressBar from another thread?
    By Xiphias in forum AWT / Swing
    Replies: 3
    Last Post: 03-18-2009, 01:48 AM
  5. Placing a JProgressBar over my JPEG image
    By hitmen in forum AWT / Swing
    Replies: 7
    Last Post: 03-08-2009, 10:16 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
  •