We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, I was using Processing 1.5.1 version and did some of my projects. I use this method, suggest from Manindra29, to call JFrame because I wanted to use two applets for data transference. It works perfect in 1.5.1, both P3D and OPENGL.
However, when I change it to 2.0.3 version recently, I found the child applet doesn't work on P3D(P2D works fine).........does anyone know how can I fix this? or any possible solutions will be worth trying. Big thanks :))))
By the way, my operating system is osx mountain lion.
here is the code
import peasy.*;
import javax.swing.JFrame;
EmbeddedSketch eSketch;
ChildApplet child = new ChildApplet();
boolean mousePressedOnParent = false;
PeasyCam cam, cam2;
public void setup() {
size(320, 240, P3D);
cam = new PeasyCam(this, 300);
eSketch = new EmbeddedSketch(child);
smooth();
}
public void draw() {
background(250);
if (mousePressed) {
fill(0);
text("Mouse pressed on parent.", 10, 10);
fill(0, 240, 0);
ellipse(mouseX, mouseY, 60, 60);
mousePressedOnParent = true;
}
else {
fill(20);
ellipse(width/2, height/2, 60, 60);
mousePressedOnParent = false;
}
box(100);
if (eSketch.sketch.mousePressed)
text("Mouse pressed on child.", 10, 30);
}
//The JFrame which will contain the child applet
public class EmbeddedSketch extends JFrame {
PApplet sketch;
public EmbeddedSketch(PApplet p) {
setBounds(100, 100, 400, 400);
add(p);
p.init();
sketch = p;
setLocation(500, 200);
//Program exits
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
}
public class ChildApplet extends PApplet {
public void setup() {
size(400, 400, P3D);
smooth();
cam2 = new PeasyCam(this, 300);
cam2.reset();
}
public void draw() {
background(0);
if (mousePressed) {
fill(240, 0, 0);
ellipse(mouseX, mouseY, 20, 20);
fill(255);
text("Mouse pressed on child.", 10, 30);
}
else {
fill(255);
ellipse(width/2, height/2, 20, 20);
}
box(100, 200, 100);
if (mousePressedOnParent) {
fill(255);
text("Mouse pressed on parent", 20, 20);
}
}
}
Answers
(i've deleted the other question)
@koogs : thanks :)>-