We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › 2 windows even with Processing ?
Page Index Toggle Pages: 1
2 windows even with Processing ??? (Read 532 times)
2 windows even with Processing ???
Mar 3rd, 2009, 12:33pm
 
Ok, you can't open 2 windows with a Processing sketch but...

is it possible for a sketch to start another one ?

And, is it possible for two sketches to communicate ?

... you see what I mean...  Smiley  ?

Re: 2 windows even with Processing ???
Reply #1 - Mar 3rd, 2009, 1:37pm
 
I would risk a yes for the first question, although it would be simpler to run them separately.
And a sure yes for the second question, a number of libraries address this need (network: Client & Server, UDP, RPC, etc.).
Re: 2 windows even with Processing ???
Reply #2 - Mar 3rd, 2009, 7:28pm
 
I'd like to know how to run a sketch from another one to have something like popup windows...
Re: 2 windows even with Processing ???
Reply #3 - Mar 3rd, 2009, 10:08pm
 
The following seems to work. Beware, I think that Swing and Processing mix can be explosive: I first tried without the noLoop() and it locked the sketch...

Code:
void setup()
{
size(300, 300);
}

void draw()
{
fill(random(0, 255));
rect(random(10, 100), random(10, 100),
random(width - 100, width - 10), random(height - 100, height - 10));
}

void keyPressed()
{
noLoop();
javax.swing.JOptionPane.showMessageDialog(this,
"You are using Processing\nThanks for your attention",
"Informational message",
javax.swing.JOptionPane.INFORMATION_MESSAGE);
loop();
}

There are variants, like asking feedback to user (OK/Cancel, Yes/No/Perhaps), etc.
Re: 2 windows even with Processing ???
Reply #4 - Mar 3rd, 2009, 11:00pm
 
Code:

import javax.swing.*;
void setup()
{
   background(0);
   stroke(255);
}

void draw()
{
 line(random(width),random(height),random(width),random(height));
}

void keyPressed()
{
 JFrame tframe = new JFrame("FrameDemo");
 //tframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 
  // create my test-applet
 MApplet m = new MApplet();
 // add it
 tframe.getContentPane().add(m, BorderLayout.CENTER);
// show it
 tframe.setVisible(true);
// size it
 tframe.setSize(300,400);
// init
 m.init();
}

public class MApplet extends PApplet{
 public void setup()
 {
   background(255);
   fill(0);
 }
 public void draw()
 {
   ellipse(random(width),random(height),random(20,50),random(20,50));
 }
}


here ya go
Re: 2 windows even with Processing ???
Reply #5 - Mar 4th, 2009, 1:23am
 
ok, when FrameDemo windows opens, I've got this error message :  (the 2nd windows is empty) :

processing.core.PGraphicsJava2D needs to be updated for the current release of Processing

I tried with Processing 0157 beta, maybe it works with Processing 1.0 ? I'm going to try with the 1.0 on another computer tomorrow !   (it isn't working on my eeepc with xandros os)

(I'm very happy because it's going to work one way or another ! Smiley  thanks for your help !  )
Re: 2 windows even with Processing ???
Reply #6 - Mar 6th, 2009, 2:19pm
 
Yet another thing I didn't know you could do from within processing.  Awesome.
Page Index Toggle Pages: 1