Schedule redraw on resize and initialization
We probably shouldn't perform frame rendering in init/setBounds. Because in onRender we can call window.setBounds. It will cause drawing onRender inside another onRender. After the fix there is no increase in artifacts on start or resize. "True" fix would be to call "repaint" instead of manual scheduling redrawing with "invokeLater", because paint events have higher priority than usual events. But "repaint" doesn't work with Canvas. It is only works with Swing components. We can extend JLayeredPane instead of HardwareLayer (and just add HardwareLayer to JLayeredPane). But there are too much changes. Anyway, system draws Window independently of AWT, so we probably can't get rid of artifacts if we use only AWT.
Showing
Please register or sign in to comment