i am developing a java swing application that doesn't fit the normal application profile. It contains a tabbed pane (and some other panels) and each tab contains a Canvas with active rendering (only one thread paints at a time).
The problem is that when i resize the main application window the canvas content doesn't show (it shows up when i stop dragging the mouse) and i cant figure why. I've also noticed that some tutorials render the content to a buffered image:
http://jamesgames.org/resources/double_buffer/double_buffering_and_active_rendering.html
Could that be the reason the Canvas is flickering (the way i understand the tutorial buffered image was only use to remove the title bar offset)?
The GUI is structured like this:
JFrame
- TabbedPane
- ScrollPane
- Canvas 1
- ScrollPane
- Canvas 2
- JPanel
- labels,buttons,..
The code:
class Renderer extends Canvas implements Runnable
{
Thread hThread = null;
BufferStrategy strategy = null;
Renderer()
{
setIgnoreRepaint(true);
}
public void run()
{
while(active)
{
g = strategy.getDrawGraphics();
draw(g); // renderer elements
strategy.show();
g.dispose();
}
}
// Called when switched to in Tabbed pane
public void start()
{
createBufferStrategy(2);
strategy = getBufferStrategy();
hThread = new Thread(this);
hThread.start();
}
// Called when switched off in Tabbed pane
public void stop(){
hThread.stop();
}
}