Open Processing draw() window in conjunction with G4P GUI Builder window

I'm successfully using G4P GUI Builder to create and manage a GUI (thanks Peter!). What I need to do now is have a second "conventional" Processing draw window open at the same time as the G4P window. Is there a more elegant way of doing this other than running a second applet as shown in the following code (this is hypothetical code -- I just created it a text editor to illustrate my point so it may will not compile):

setup()  // Main Setup routine
{
    //Usual setup code here
    //
    // G4P GUI Builder setup
    size(1300, 320, JAVA2D);
    createGUI();
    customGUI();

    // Start up second applet with it's own draw window
    String[] args = {"New Window Caption"};
    MySecondWindowClass swc = new MySecondWindowClass();
    PApplet.runSketch(args, swc); // Run the second applet
}

// SECOND APPLET FOR CONVENTION PROCESSING DRAW WINDOW
public class MySecondWindowClass extends PApplet
{

    setup()  // Setup for second applet
    {
        size(1000,500); // For second window
    }

    draw() // Draw for second applet
    {
        textSize(10);
        textAlign(LEFT,TOP);
        text("Hello world!")    // Text to be displayed on second window (not the G4P window)
    }
}

The idea, of course, is to be able to do all the cool things one can do with Processing in the second draw window leaving the GUI window untouched.

Thanks in advance, Andy

Tagged:

Answers

Sign In or Register to comment.