File Chooser2
2A built in hybrid ruby/java library
Start by loading in the chooser library, the purpose of this library is to allow you to use the vanilla processing interface to the native file chooser
(it is almost impossible to use vanilla processing reflection methods without this sort of wrapper)
load_library :chooser
def setup
java_signature 'void selectInput(String, String)'
selectInput('Select a file to process:', 'fileSelected')
end
def fileSelected(selection)
if selection.nil?
puts 'Window was closed or the user hit cancel.'
else
puts format('User selected %s', selection.get_absolute_path)
end
end
See also these examples