I’ve read through the Swing and Processing as a Java Library tutorials, and I’m trying to combine the two to create a Swing application that contains a Processing sketch.
I’ve tried this:
import javax.swing.JFrame;
import processing.core.PApplet;
public class MySketch extends PApplet{
public void settings(){
size(500, 500);
}
public void draw(){
background(255, 0, 0);
fill(0, 255, 0);
ellipse(width/2, height/2, width, height);
}
public static void main(String[] args){
JFrame frame = new JFrame("Processing Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//The method add(Component) in the type Container is not applicable for the arguments (MySketch)
frame.add(new MySketch());
frame.setSize(500, 500);
frame.setVisible(true);
}
}
But I get an error saying The method add(Component) in the type Container is not applicable for the arguments (MySketch)
How can I add a Processing sketch into a Swing application?