Draw 'Component' to Bitmap


is it possible to draw manually the content (graphics) of a component to a bitmap? I have a display in my plugin that have to update sometimes automatically and i set a flag to call the repaint method when it is necessary. Whe the flag is true, the method draw some sexy lines, but when it is false, then the lines are not drawn. I donßt want to recall the repaint method at every frame so it would be nice if it is possible to cache the result into a bitmap and draw the bitmap if there are no changes.

how can i do this?

greetz from germany

Have a read about setBufferedToImage

ok thanks. I tried it but have problems with it. I wrote this code, it´s very simple, but gives error at runtime…

void DelayDisplay::paint(Graphics& g)
	if (haveToRepaint() == false)

bool DelayDisplay::haveToRepaint()
	if (_timeL != _timeLOld || _timeR != _timeROld)
		_timeLOld = _timeL;
		_timeROld = _timeR;
		if (_buffering == true)
			_buffering = false;
		return true;
	if (_buffering == false)
		_buffering = true;
	return false;

void DelayDisplay::paint(Graphics& g) { if (haveToRepaint() == false)

If paint() gets called, there will be a redraw if you want or not, so this makes no sense.
If you want no redraw, than you have to care that nobody calls repaint() and that not background/foreground redraw causes dirty regions in the component, maybe though making the component opaque (setQpaque)

it works, thx a lot.