Swing Components in Default ProcessingWindow

Great! Yes, and with lambdas (which I believe Processing 4 now supports in the language?) it can be a one-liner EventQueue.invokeLater(this::buildWnd); And I prefer using the java.awt.EventQueue directly - amounts to same thing though.

Unfortunately Processing misses the same ability, so passing tasks back into the Processing animation thread takes a little more work. You can use a java.util.concurrent.ConcurrentLinkedQueue<Runnable> and drain and run every task at the start of draw(). Mind you, not useful in your example as that would destroy the rendering, although you should be able to add components around the Processing rendering I think.

1 Like