Problem with JProgressBar

I'm trying to use a JProgressBar in my application (using indeterminate mode), but the progressBar is set to indeterminate mode only after the method gen.generate(file) is executed. I want the progressBar to work as long as the gen.generate(file) being executed.

this is the problematic part:

if (e.getSource() == sign) {

openButton.setEnabled(false);

verify(false);

sign.setEnabled(false);

setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

progressBar.setIndeterminate(true);

genSig gen = new genSig();

gen.generate(file);

}

[602 byte] By [gilberoa] at [2007-11-26 14:53:01]
# 1

It does. You're just not giving any chance to do something.

Your thread does:

- set progress bar

- paint()

- do all the work

- paint()

Note how no painting happens *during* working, which is what you want to have. You need a new thread.

http://java.sun.com/docs/books/tutorial/uiswing/concurrency/

CeciNEstPasUnProgrammeura at 2007-7-8 8:41:18 > top of Java-index,Java Essentials,Java Programming...
# 2

In the future, Swing related questions should be posted in the Swing forum.

Use the "Code" formatting tags when posting code so the code retains its original formatting.

Read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html]How to Use Progress Bars[/url].

camickra at 2007-7-8 8:41:18 > top of Java-index,Java Essentials,Java Programming...
# 3
you are right, and I tried using SwingWorker, but for some reason I couldn't override doInBackground propertly, any tips?
gilberoa at 2007-7-8 8:41:18 > top of Java-index,Java Essentials,Java Programming...
# 4
never mind I got it, just used a simple thread to run my method in the background. thanks
gilberoa at 2007-7-8 8:41:18 > top of Java-index,Java Essentials,Java Programming...