Posted by cbare
on September 24, 2008 at 10:42 PM PDT
I'm trying to build a little program that draws complicated time-consuming plots. I'd like to avoid having my UI freeze up while I'm rendering, so I don't want to do the rendering on the event dispatch thread. So, what's the modern (well, Java 5 level of modern) way of doing this?
First, should I be drawing on a Canvas or a JPanel? I'm using Swing components in the rest of my app and I've read that you're not supposed to mix Swing and AWT, but I can switch if there's good reason.
Next, do I want to use VolatileImage, BufferStrategy, or something else? Can you even get a BufferStrategy for a JPanel? I'd like to get hardware double buffering, if possible.
Last, I assume it's OK to draw on the offscreen image on another thread and then put a runnable on the event dispatch thread to do the blt? Or is that the wrong way to go about it?
Any pointers to the current (JDK1.5) wisdom would be appreciated! Thanks,