You should start a bit further back, understanding how processing pre-processes a *.pde is very instructive:-
Processing caches it’s compiled java classes and a .java file every time you run a sketch, Apple will change where in the /var/folders/ directory this is. The fastest way to find the current location is to create a new sketch, don’t save it and press command+k which will open up the subdirectory of /var/folders/ where the sketch is temporarily stored.
Anyway should basically check that you understand what is going on, this will set you in good stead. Basically processing creates inner classes so that they can inherit methods etc from PApplet, you might not want to do that so, you need to know that you can access static methods using PApplet or instance methods on your instance of PApplet.
The class containing processings setup, settings, and draw methods should also contain your main method.
All other classes that are not processing sketches don’t need to extend PApplet.
If you want to have those classes use processing methods like “point(x, y)” for example, you will have to pass your main class (“Mouse” in this case)
import processing.core.PApplet;
public class Mouse extends PApplet {
public static void main(String[] args)
{
PApplet.main("Mouse");
}
ExampleClass myExampleClass; //Declare instance of your class
public void setup()
{
background(0);
}
public void settings()
{
size(800, 800);
myExampleClass = new ExampleClass(this); //Initialize instance by passing a reference to your main class
//using the "this" keyword.
}
public void draw()
{
stroke(255);
line(0, 0, mouseX, mouseY);
myExampleClass.drawPoint(mouseX, mouseY);
}
}
and then for example:
import processing.core.PApplet;
public class ExampleClass
{
private PApplet parent;
public ExampleClass(PApplet parent) // This will take your main class as an argument to use later on
{
this.parent = parent;
}
public void drawPoint(int x, int y)
{
parent.point(x, y); //Use processing methods like this in other classes.
}
}
Are you looking to have multiple windows? Then I would use your first code in your first post with some modifications. However, your question is about working with multiple classes. It is possible but you need to be aware how to access the main sketch and only access it if you need to. For instance, if you have a class which is design to sort your data, then this class does not need to have access to the PApplet. Instead, you can pass data to the PApplet. You can do this by instantiating the object within the main sketch and then passing a reference of the PApplet to it as describe by @cumulus in the previous post. However, the most effective way is to return the data to the sketch so it can handle it. What strategy to implement depends on what you want to do and it is the fun part of the designing stage.