The problem is that the code in the linked topic although works to some extent it is not the best way to have a second window.
I have modified the code so that each window reports the current position of the mouse when it is over the window. Notice that when the cursor moves off a window the mouse position is 'frozen' at the last value reported (this is normal), but the window is still drawing as you can see from the progress bar.
Although this works well for a second window it is not good if you want multiple windows. If you do I suggest that you use the G4P (guicomponents) library which not only provides a range of GUI controls but supports multiple windows. The libray comes with 2 examples
Simple windows starter (creates 3 sub windows when you click on the button)
Mandelbrot (creates a new window whenever you drag a box over any of the mandelbrot windows)
- PFrame f;
- void setup() {
- size(320, 240);
- PFrame f = new PFrame();
- }
- void draw() {
- background(255, 200, 200);
- stroke(0);
- fill(255, 0, 0);
- rect(0, 20, frameCount % width, 10);
- text(""+mouseX+", "+mouseY, 20, 60);
- }
- public class PFrame extends Frame {
- PApplet app;
- public PFrame() {
- setBounds(100, 100, 400, 300);
- app = new SubApplet1();
- add(app);
- app.init();
- show();
- }
- }
- public class SubApplet1 extends PApplet {
- void setup() {
- size(400, 300);
- }
- void draw() {
- background(200, 200, 255);
- stroke(0);
- fill(0, 0, 255);
- rect(0, 20, frameCount % width, 10);
- text(""+mouseX+", "+mouseY, 20, 60);
- }
- }