We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, I'm trying to load some sketches within a "master" sketch. I found a neat blog post about it, but am stuck at the stage where child sketches are loaded into the master sketch: Processing can’t find the sketches I’m trying to load. Here's the relevant code. Mine is effectively identical. In the load method, I get java.lang.ClassNotFoundException. If I try myself with PApplet sketch = new Sketchname(), I get “Cannot find class or type Sketchname”. I found a clever way of loading sketches via reflection, but when I try
Class[] classes = getClass().getDeclaredClasses();
int n = classes.length;
I get n = 0
.
I think this might be due to the sketches not being in the same package. Could this be? I don’t have a package declaration at all, because when I tried to add package org.myorg.something (as the very first line), I got “syntax error on “package”, delete this token”. My sketches are located in the file system like sketchbook/Sketchname.
Any idea what this could be caused by? And how to fix it? I'm using Processing 2.2.1.
Answers
Perhaps my multi-instance PApplet instantiation example might be of some help?
http://forum.processing.org/two/discussion/7036/multiple-screens
It is, thanks, but the problem persists. In your example, I take it you have all the classes defined in the same .pde file? I'd like to have one class per file. When I did
I got class
processing.core.PApplet$RendererChangeException class java.awt.Component$BaselineResizeBehavior
.I tried changing my class signature to
public static class Classname
, but to no avail. My sub-sketches are still not visible to the master sketch. I think it's a scoping problem, but I don't know what to do about it.If we wish, we can place whole classes in separate ".pde" tabs.
Later PDE's pre-processor will concatenate everything as 1 ".java" file before compilation.
Take notice that PDE's pre-processor got its own template for
static void main(String[] args) {}
What I did was replacing it w/ my own which instantiates not only the main sketch, but also any nested
public static class
whichextends PApplet
. :-BI'll leave you w/ a more complete example here from: http://forum.processing.org/two/discussion/7202/controlp5-controlwindow-and-controlp5frame
It's got a main sketch plus 2 nested sketches: :bz