W10
Processing 4.3
This example works with consistency here:
< Click here to open !
void setup()
{
}
void draw()
{
}
void mousePressed()
{
String path = sketchPath();
path = "E:\\Pictures\\2017-08-10\\Set 01"; // Set an existing path on your system
println(path);
File f = new File(path);
println(f.getAbsolutePath());
selectInput("open file", "openFile", f);
}
void openFile(File selection)
{
println("File selected:", selection);
}
This text will be hidden
Improved version of above:
< Click here to open !
/*
Project: selectInPut() to a default folder
Author: GLV
Date: 2024-08-25
Version: 1.0.1
*/
// Addresses dialog behind sketch window:
// https://github.com/processing/processing/issues/3775
//import processing.javafx.*; // If using this renderer
PImage img;
void setup()
{
size(800, 600);
//size(800, 600, FX2D);
//size(800, 600, P2D);
//size(800, 600, P3D);
noLoop();
}
void draw()
{
if(img != null)
{
img.resize(width, height);
image(img, 0, 0);
}
}
void mousePressed()
{
surface.setVisible(false);
String path = sketchPath();
//path = "E:\\Pictures\\2017-08-10\\Set 01\\*"; // Set an existing path on your system
String username = System.getProperty("user.name");
path = "D:\\users\\" + username + "\\Pictures\\*"; // Set path to pictures. May differ on your PC.
//println(path);
File f = new File(path);
println(f.getAbsolutePath());
selectInput("open file", "openFile", f);
}
void openFile(File selection)
{
if (selection != null)
{
println("File selected:", selection);
String s = selection.toString();
img = loadImage(s);
}
surface.setVisible(true);
redraw();
}
Related Processing 4.3 Github Issue:
:)