Skip to content
Advertisement

How to open multiple windows with Processing?

I’m trying to create two windows with Processing. Before you mark this as a duplicate, as there are other questions similar to this, I have a specific error and I can’t find a solution. When I try to add(s) I get the error The method add(Component) in the type Container is not applicable for the arguments (evolution_simulator.SecondApplet)

I’m not sure how to fix this, and any help would be appreciated. Here is the code:

JavaScript

Advertisement

Answer

The reason for the error message is because the add() function is expecting a Component, and PApplet is not a Component. This is because PApplet no longer extends Applet as of Processing 3, so old code that uses it as a Component will no longer work.

Instead, you can create a class that extends PApplet for your second window, and then call PApplet.runSketch() using that second PApplet as a parameter:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement