Is it possible to perform active rendering in Java Swing without being on the EDT?

前端 未结 2 1071
生来不讨喜
生来不讨喜 2021-01-19 07:14

I am looking into using Buffer Strategy and the following technique described on the Javadoc:

// Main loop
while (!done) {
 // Prepare for rendering the next         


        
2条回答
  •  隐瞒了意图╮
    2021-01-19 07:24

    In general, no. Painting on a thread other than the event dispatch thread (EDT) results in undesirable artifacts, although the results may be acceptable. This example demonstrates some of the trade-offs. I prefer arranging to draw on the EDT using javax.swing.Timer, but other approaches are possible. Also, your chosen top-level Container may already implement a Buffer Strategy.

提交回复
热议问题