JProgressBar problem

Dear experts,

I just completed developing a sudoko game.In the game there is a

process having multiple for /while loops.While this process is going on ,

at times user becomes idle.I want that a progressbar should continously show increment of processing.

I added a progressbar and used setValue() of current status value.

However in for/while loops there is no progress visible.

However when loop is over i get 100% and progress bar at top.

Using a secondary approach i tried Thread class and invoked run().

This too has gone in vain.Then i used setPriority method but not working.How to proceed ?

[652 byte] By [Adi1000a] at [2007-11-27 7:12:57]
# 1

After almost 400 postings in the forum you should know that Swing related questions should be posted in the Swing forum.

But there is no need to repost the question since the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html]How to Use Progress Bars[/url] has working examples.

camickra at 2007-7-12 19:03:53 > top of Java-index,Java Essentials,Java Programming...
# 2
Look at yeild and sleep in the thread class. You need to tell your executing process to yeild so your status can update.
morgalra at 2007-7-12 19:03:53 > top of Java-index,Java Essentials,Java Programming...
# 3
I had tried sleep too.The time i give is 1 sec.No change.
Adi1000a at 2007-7-12 19:03:53 > top of Java-index,Java Essentials,Java Programming...
# 4
You don't use sleep(). You use a separate Thread, which is demonstrated in the tutorial. So take a few minutes to read the tutorial.
camickra at 2007-7-12 19:03:53 > top of Java-index,Java Essentials,Java Programming...
# 5

Dear friends i have tried numerous ways like

try {

SwingUtilities.invokeLater(new Runnable() {

public void run() {

it.updateBar(percent);

}

});

java.lang.Thread.sleep(100);

} catch (InterruptedException e) {

;

}

Then further i applied a different way by implementing ChangeListener

interface and defining in statechanged() abstract method the above snippet

try {

new Runnable() {

public void run() {

pb.setValue(gb);

}

};

java.lang.Thread.sleep(100);

} catch (InterruptedException ex) {

;

}

All techiniques have failed.Any further ?

Adi1000a at 2007-7-12 19:03:53 > top of Java-index,Java Essentials,Java Programming...
# 6
> All techiniques have failed.Any further ? So why does the code from the tutorial work?We can't tell what you are doing based on a few random line of code. Copy the structure of code from the tutorial and incorporate it into your code.
camickra at 2007-7-12 19:03:53 > top of Java-index,Java Essentials,Java Programming...