I’m searching for a way to paint several JComponents
above each other (overlap) and still being able to individually access and alter them.
E.g. paint three JPanels
with transparent backgrounds – each containing a circle, a rectangle or a line.
Afterwards, I’d like to change the appearance of the circle. The other two should not be repainted (similarly to layers in Photoshop).
My current project has a Jpanel
with thousands of lines and I need to change a rectangle in the back on mouseover if I redraw the complete Jpanel
each time it is very laggy.
Is there a decent way to accomplish that? Thank you already for your ideas!
2
Answers
It worked quite fine - here is my code if anyone else has a similar problem! the first image can be stored and displayed later on (buff) Make sure to generate new BufferedImage (here canvas) when displaying again, as the transperency is lost otherways. Thanks to Gilbert Le Blanc
You can invoke:
to specify the Rectangular area to be repainted.