You can simplify your example even further. Try to get rid of images and classes. Like this:
void setup() {
size(400, 400);
}
void draw() {
if (mouseX >= width/2 && mousePressed) {
selectOutput("Select a file to write to:", "fileSelected");
}
}
void fileSelected(File selection) {
if (selection == null) {
println("Window was closed or the user hit cancel.");
} else {
println("User selected " + selection.getAbsolutePath());
}
}
This code is roughly equivalent to yours, without any extra code or dependencies.
The problem with this code is that you’re calling selectInput() from inside the draw() function. This is causing 60 dialogs per second to display, which is breaking your sketch.
To fix this, you need to prevent multiple dialogs from popping up: you could add a boolean variable that tracks this, or you could move your logic into the mousePressed() function.