Can anyone give insight as to why a JPanel that is drawing simple shapes such as rectangles, in small quantity, could lag noticeably when resizing the frame?
I think that by adding an event for window resize and timing the resize to 1/10 s or so, I could solve the problem. But I'm not so sure.
EDIT:
After reviewing the example code I found that the resize lag is due to having a handler that scales drawn objects by getting the height and width of the screen.
this.addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent e) {
setScale( getHeight(), getWidth() );
}
});
Is there any way to smooth the resize lag?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…