How to make progress bar during paint Thread?

Hi all,

in my program, I need to render a complex image which take several seconds, so I need to show a swing progress bar. During computing, I use 3D renderer to get different images of 3d scene, and 3d view is in a Awt Canvas (LWJGLCanvas exactly).

That's why I execute my render fonction in a OpenGL thread like this :

Callable<?> call = new Callable<Runnable>() {
               public synchronized Runnable call() throws Exception {
                            _3dView.getJmePanel().getRenderer(), tool);
                  return null;

The problem is that my render function update progressBar (with "tool" object), but bar doesn't repaint because all repaint threads are blocked by the LWJGLCanvas paint, which call my render function.

So is there any solution to separate paint Thread using OpenGL and Swing paint for Components ? Or a solution to do render directly with OpenGL without repaint function ?


Have you tried repaintImmediatly() rather than just repaint()?

(Also, why not use openGL instead to render a progress bar?)

Thanks a lot, it works with paintImmediatly.() I didn't know this function. :wink:

To answer your question, I couldn't use openGL to render the progress bar, simply because 3D view is used to do rendering so it is frozen, and also because is not visible during rendering.

Thanks again basixs :slight_smile: