나는 Buffer Strategy을 사용하여에보고하고 다음과 같은 기술은 자바 독에 설명 : 애니메이션을 수행 할 때EDT없이 Java Swing에서 활성 렌더링을 수행 할 수 있습니까?
// Main loop
while (!done) {
// Prepare for rendering the next frame
// ...
// Render single frame
do {
// The following loop ensures that the contents of the drawing buffer
// are consistent in case the underlying surface was recreated
do {
// Get a new graphics context every time through the loop
// to make sure the strategy is validated
Graphics graphics = strategy.getDrawGraphics();
// Render to graphics
// ...
// Dispose the graphics
graphics.dispose();
// Repeat the rendering if the drawing buffer contents
// were restored
} while (strategy.contentsRestored());
// Display the buffer
strategy.show();
// Repeat the rendering if the drawing buffer was lost
} while (strategy.contentsLost());
}
EDT 및 invokeLater
또는 invokeAndWait
을 피하기 위해 좋은 것입니다.
내 질문 : 이것은 우리가 동부 서머 타임에 show
에 전화를 넣어 대해 걱정할 필요가 없습니다 스윙 응용 프로그램에있는 경우
- ?
- 누구든지 Swing 앱에서이 문제를 사용하여 문제를 볼 수 있습니까?
이것은 게임 프로그래밍에 대해 interesting answer에서 영감을 얻었습니다.