Quote:Actually, the viewer is the main program. The child class is the control panel, and the main reason I wanted to encapsulate it was to get rid of all the slider and label code on my setup() function. So I made a LorenzController class, and in my constructor I have:
It would probaly be easier the other way round it would then be possible to have a single control panel that can control different views of the Lorenz Attractor in separate windows. Look at how the Manelbrot code is used, but what you want to do is not impossible.
If you want the control panel to be sub window then the following might make it clearer how G4P works.
First consider a single window Processing sketch the main window is based on the PApplet class which contains a graphics context to draw on - all the commands such as stroke(), pushMatrix() etc use the methods in PApplet and the graphics context.
When you create a GUI object such as GSlider the first attribute is always a reference to the PApplet object responsible for drawing the GUI component.
In the examples the GUI components are created in the main window and then added to the GWindow using the GWindow add() method - this changes the PApplet responsible for drawing the object to the one in the GWindow.
When you create a GWindow you are creating an object that extends the java.awt.Frame class to get the actual window but the GWindow ctor also creates a new GWinApplet object which is a subclass of PApplet to get the drawing area.
Ok so going to your child class ctor
Code: super(_theApplet, "Visualizer", 650, 100, 600, 275, false, null); //that's the first line of code
this.addData(new GWinData());
// init stuff...
this.addDrawHandler(this, "visualizerDraw"); //correct?
After the call to the GWindow ctor using super(....) the GWinApplet will have been created, it should be possible to use this in your GWindow subclass to create and add GUI components. The name of the GWinApplet object is 'embed' so in your ctor you could do something like
Code: super(_theApplet, "Visualizer", 650, 100, 600, 275, false, null); //that's the first line of code
this.addData(new GWinData());
// init stuff...
slider = new GSlider(embed, ...);
this.addDrawHandler(this, "visualizerDraw"); //correct?
Where slider is a GSlider attribute of your child class. The event handlers for GSlider would also be in your child class.
Hope this helps.