Hi @glv, amazing!
I totally appreciate you taking the time to share this!
It works!
I also modified it a little bit so it will work to select a directory instead of just a folder:
// Code from these links was modified:
//https://forum.processing.org/beta/num_1140487204.html
//https://stackoverflow.com/questions/13516829/jfilechooser-change-default-directory-in-windows
import javax.swing.*;
PImage img;
boolean loaded = false;
void setup()
{
size(500, 500);
}
void draw()
{
if(loaded)
{
image(img, 0, 0);
println(img.width);
}
}
void mousePressed()
{
launchChooser();
}
void launchChooser()
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
loaded = false;
try
{
JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fc.setCurrentDirectory(new File("/Users/Username/Documents/SomeFolder"));
fc.setDialogTitle("Select a folder");
int returnVal = fc.showOpenDialog(null);
if (returnVal == JFileChooser.APPROVE_OPTION)
{
File file = fc.getSelectedFile();
//String name = file.getName().toLowerCase();
//if (name.endsWith(".png") || name.endsWith(".gif"))
// {
//img = loadImage(file.getAbsolutePath());
println(file.getAbsolutePath());
//loaded = true;
//println(loaded, img.width, img.height);
//}
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
);
}
What about selectOutput() command to select a file?
I’m wondering why processing hasn’t done anything in 11 years with this - it seems like an important thing to have as part of the language!
I totally appreciate your time, so again, THANK YOU for your expertise!!!
Mike