Yesterday I found the following code for creating a second window in Processing
import javax.swing.JFrame;
PFrame f;
secondApplet s;
void setup() {
size(600, 340);
}
void draw() {
background(255, 0, 0);
fill(255);
}
void mousePressed(){
PFrame f = new PFrame();
}
public class secondApplet extends PApplet {
public void setup() {
size(600, 900);
noLoop();
}
public void draw() {
fill(0);
ellipse(400, 60, 20, 20);
}
}
public class PFrame extends JFrame {
public PFrame() {
setBounds(0, 0, 600, 340);
s = new secondApplet();
add(s);
s.init();
println("birh");
show();
}
}
And edited...
void mousePressed(){
PFrame f = new PFrame();
}
Into:
if(mousePressed && mouseX > 1050 && mouseX < 1350 && mouseY > 700 && mouseY < > 750) {
f = new PFrame();
}
}
It worked lovely, but since I downloaded and installed Processing III, I've got the following errors:
- The function
add()
expects parameters likeadd(component)
. - The function
init()
does not exist. - The method
show()
from the type window is deprecated.