The function “setBufferedToImage” is not working for me.
I have a component, which is opaque. It has the name “TestComp”. I also set “setBufferedToImage(true)” on this component.
Inside the component I have a TextButton. But still, every time the mouse enters the TextButton, the paint() routine for TestComp is called. I expected it to use its buffered image instead. But it is not doing that. What am I doing wrong?
While the main component may be opaque, your test button component isn’t which will cause repainting for parent components or any components that may overlap it
I understand that the main component (=TestComp) needs to repaint. But I told it to use the buffered image. So it should us the buffered image for repainting. Why does it not use that?
I must be misunderstanding something here, I guess. But isn’t this the typical situation, a buffered image is made for?
The image is reclaculated any time the component has its repaint() function called, which in this case happens every time the child button is interacted with.
For example if your button was set as buffered to an image instead and the parent was repainted, the button internally should use the buffered image instead of running its whole paint() function. If you were to call button.repaint() then the entire buffered image would be recalculated
AFAIK you can create a background-class, where you put the contents of your paint method you want to buffer, and use this background class as a member of your TestComp class. When the background is bufferedToImage, it should work.