I mainly draw a lot of transparent JPanels; profiling shows that most of the time is spent in Component.paint (). This could be optimized quite radically, since in most cases the real opaque area on JPanel is quite small, for example, along the edges.
As of now, repainting () a component will cause a repaint of all its parents, since the RepaintManager cannot know that the dirty parent area is actually opaque and will move up the component hierarchy. I thought about calling markCompletelyClean() for all parents whenever the panel is invalid and itself controls dirty areas with addDirtyRegion() .
However, is there a cleaner approach for marking only certain JPanel rectangles as opaque (or transparent, doesn't matter)?
source share